Use different assertions for Rails 5 and 6
Rails 6 changed the way it sanitizes input values. References: - 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
This commit is contained in:
parent
6f677ec0e9
commit
13d0341bdf
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue