@@ -45,8 +45,17 @@ def with_collection_check_boxes(object, attribute, collection, value_method, tex
45
45
46
46
test "collection radio sanitizes collection values for labels correctly" do
47
47
with_collection_radio_buttons @user , :name , [ '$0.99' , '$1.99' ] , :to_s , :to_s
48
- assert_select 'label.collection_radio_buttons[for=user_name_099]' , '$0.99'
49
- assert_select 'label.collection_radio_buttons[for=user_name_199]' , '$1.99'
48
+
49
+ # Rails 6 changed the way it sanitizes the values
50
+ # https://github.com/rails/rails/blob/6-0-stable/actionview/lib/action_view/helpers/tags/base.rb#L141
51
+ # https://github.com/rails/rails/blob/5-2-stable/actionview/lib/action_view/helpers/tags/base.rb#L141
52
+ if ActionView ::VERSION ::MAJOR == 5
53
+ assert_select 'label.collection_radio_buttons[for=user_name_099]' , '$0.99'
54
+ assert_select 'label.collection_radio_buttons[for=user_name_199]' , '$1.99'
55
+ else
56
+ assert_select 'label.collection_radio_buttons[for=user_name_0_99]' , '$0.99'
57
+ assert_select 'label.collection_radio_buttons[for=user_name_1_99]' , '$1.99'
58
+ end
50
59
end
51
60
52
61
test "collection radio checks the correct value to local variables" do
@@ -292,8 +301,17 @@ def with_collection_check_boxes(object, attribute, collection, value_method, tex
292
301
293
302
test "collection check box sanitizes collection values for labels correctly" do
294
303
with_collection_check_boxes @user , :name , [ '$0.99' , '$1.99' ] , :to_s , :to_s
295
- assert_select 'label.collection_check_boxes[for=user_name_099]' , '$0.99'
296
- assert_select 'label.collection_check_boxes[for=user_name_199]' , '$1.99'
304
+
305
+ # Rails 6 changed the way it sanitizes the values
306
+ # https://github.com/rails/rails/blob/6-0-stable/actionview/lib/action_view/helpers/tags/base.rb#L141
307
+ # https://github.com/rails/rails/blob/5-2-stable/actionview/lib/action_view/helpers/tags/base.rb#L141
308
+ if ActionView ::VERSION ::MAJOR == 5
309
+ assert_select 'label.collection_check_boxes[for=user_name_099]' , '$0.99'
310
+ assert_select 'label.collection_check_boxes[for=user_name_199]' , '$1.99'
311
+ else
312
+ assert_select 'label.collection_check_boxes[for=user_name_0_99]' , '$0.99'
313
+ assert_select 'label.collection_check_boxes[for=user_name_1_99]' , '$1.99'
314
+ end
297
315
end
298
316
299
317
test "collection check box checks the correct value to local variables" do
0 commit comments