diff --git a/test/action_view_extensions/builder_test.rb b/test/action_view_extensions/builder_test.rb index 569d2398..974013c5 100644 --- a/test/action_view_extensions/builder_test.rb +++ b/test/action_view_extensions/builder_test.rb @@ -45,8 +45,17 @@ class BuilderTest < ActionView::TestCase test "collection radio sanitizes collection values for labels correctly" do with_collection_radio_buttons @user, :name, ['$0.99', '$1.99'], :to_s, :to_s - assert_select 'label.collection_radio_buttons[for=user_name_099]', '$0.99' - assert_select 'label.collection_radio_buttons[for=user_name_199]', '$1.99' + + # Rails 6 changed the way it sanitizes the values + # https://github.com/rails/rails/blob/6-0-stable/actionview/lib/action_view/helpers/tags/base.rb#L141 + # https://github.com/rails/rails/blob/5-2-stable/actionview/lib/action_view/helpers/tags/base.rb#L141 + if ActionView::VERSION::MAJOR == 5 + assert_select 'label.collection_radio_buttons[for=user_name_099]', '$0.99' + assert_select 'label.collection_radio_buttons[for=user_name_199]', '$1.99' + else + assert_select 'label.collection_radio_buttons[for=user_name_0_99]', '$0.99' + assert_select 'label.collection_radio_buttons[for=user_name_1_99]', '$1.99' + end end test "collection radio checks the correct value to local variables" do @@ -292,8 +301,17 @@ class BuilderTest < ActionView::TestCase test "collection check box sanitizes collection values for labels correctly" do with_collection_check_boxes @user, :name, ['$0.99', '$1.99'], :to_s, :to_s - assert_select 'label.collection_check_boxes[for=user_name_099]', '$0.99' - assert_select 'label.collection_check_boxes[for=user_name_199]', '$1.99' + + # Rails 6 changed the way it sanitizes the values + # https://github.com/rails/rails/blob/6-0-stable/actionview/lib/action_view/helpers/tags/base.rb#L141 + # https://github.com/rails/rails/blob/5-2-stable/actionview/lib/action_view/helpers/tags/base.rb#L141 + if ActionView::VERSION::MAJOR == 5 + assert_select 'label.collection_check_boxes[for=user_name_099]', '$0.99' + assert_select 'label.collection_check_boxes[for=user_name_199]', '$1.99' + else + assert_select 'label.collection_check_boxes[for=user_name_0_99]', '$0.99' + assert_select 'label.collection_check_boxes[for=user_name_1_99]', '$1.99' + end end test "collection check box checks the correct value to local variables" do