From 46fb7d8b387c17549a242b07ebd95476bb7584f5 Mon Sep 17 00:00:00 2001 From: Serene Yew Date: Wed, 17 Jul 2024 03:02:44 -0600 Subject: [PATCH] [#2996] - Change boolean field to show dash when null (#2997) * Change boolean field to show dash when null * Update app/components/avo/fields/boolean_field/index_component.html.erb * Update app/components/avo/fields/boolean_field/show_component.html.erb --------- Co-authored-by: Paul Bob <69730720+Paul-Bob@users.noreply.github.com> --- .../boolean_field/index_component.html.erb | 2 +- .../boolean_field/show_component.html.erb | 2 +- spec/system/avo/boolean_field_spec.rb | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 spec/system/avo/boolean_field_spec.rb diff --git a/app/components/avo/fields/boolean_field/index_component.html.erb b/app/components/avo/fields/boolean_field/index_component.html.erb index 445f9d9f6c..fb7a33c854 100644 --- a/app/components/avo/fields/boolean_field/index_component.html.erb +++ b/app/components/avo/fields/boolean_field/index_component.html.erb @@ -1,3 +1,3 @@ -<%= index_field_wrapper **field_wrapper_args, dash_if_blank: false, flush: true do %> +<%= index_field_wrapper **field_wrapper_args, flush: true do %> <%= render Avo::Fields::Common::BooleanCheckComponent.new checked: @field.value %> <% end %> diff --git a/app/components/avo/fields/boolean_field/show_component.html.erb b/app/components/avo/fields/boolean_field/show_component.html.erb index a9f5672503..ffee935ed8 100644 --- a/app/components/avo/fields/boolean_field/show_component.html.erb +++ b/app/components/avo/fields/boolean_field/show_component.html.erb @@ -1,3 +1,3 @@ -<%= field_wrapper **field_wrapper_args, dash_if_blank: false do %> +<%= field_wrapper **field_wrapper_args do %> <%= render Avo::Fields::Common::BooleanCheckComponent.new checked: @field.value %> <% end %> diff --git a/spec/system/avo/boolean_field_spec.rb b/spec/system/avo/boolean_field_spec.rb new file mode 100644 index 0000000000..c4f0dc1bc3 --- /dev/null +++ b/spec/system/avo/boolean_field_spec.rb @@ -0,0 +1,17 @@ +require "rails_helper" + +RSpec.describe "BooleanField", type: :system do + describe "with regular input" do + let!(:post) { create :post, name: "My Post", is_featured: nil } + + context "show" do + it "displays the post values" do + visit "/admin/resources/posts/#{post.id}" + + expect(page).to have_text "IS FEATURED" + + expect(find_field_value_element("is_featured")).to have_text empty_dash + end + end + end +end