diff options
author | Gannon McGibbon <gannon.mcgibbon@gmail.com> | 2019-02-05 13:42:33 -0500 |
---|---|---|
committer | Gannon McGibbon <gannon.mcgibbon@gmail.com> | 2019-02-05 13:48:25 -0500 |
commit | 7caea98e189c02721b2e944a074c405b033852eb (patch) | |
tree | d6f384f3608065c84b2dc3ddc79a1579fd792a21 /actionview/test/template | |
parent | deca8c52300ff59a98a138f94a33834725511a0b (diff) | |
parent | f8696b888e6ac2984927a074de60b2c5bad9bc59 (diff) | |
download | rails-7caea98e189c02721b2e944a074c405b033852eb.tar.gz rails-7caea98e189c02721b2e944a074c405b033852eb.tar.bz2 rails-7caea98e189c02721b2e944a074c405b033852eb.zip |
Merge branch 'float_dom_ids'
Closes #34975.
Diffstat (limited to 'actionview/test/template')
-rw-r--r-- | actionview/test/template/form_collections_helper_test.rb | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/actionview/test/template/form_collections_helper_test.rb b/actionview/test/template/form_collections_helper_test.rb index 6db55a1447..ca117d4a30 100644 --- a/actionview/test/template/form_collections_helper_test.rb +++ b/actionview/test/template/form_collections_helper_test.rb @@ -48,8 +48,16 @@ class FormCollectionsHelperTest < ActionView::TestCase test "collection radio should sanitize collection values for labels correctly" do with_collection_radio_buttons :user, :name, ["$0.99", "$1.99"], :to_s, :to_s - assert_select "label[for=user_name_099]", "$0.99" - assert_select "label[for=user_name_199]", "$1.99" + assert_select "label[for=user_name_0_99]", "$0.99" + assert_select "label[for=user_name_1_99]", "$1.99" + end + + test "collection radio correctly builds unique DOM IDs for float values" do + with_collection_radio_buttons :user, :name, [1.0, 10], :to_s, :to_s + assert_select "label[for=user_name_1_0]", "1.0" + assert_select "label[for=user_name_10]", "10" + assert_select 'input#user_name_1_0[type=radio][value="1.0"]' + assert_select 'input#user_name_10[type=radio][value="10"]' end test "collection radio accepts checked item" do @@ -302,8 +310,16 @@ class FormCollectionsHelperTest < ActionView::TestCase test "collection check box should sanitize collection values for labels correctly" do with_collection_check_boxes :user, :name, ["$0.99", "$1.99"], :to_s, :to_s - assert_select "label[for=user_name_099]", "$0.99" - assert_select "label[for=user_name_199]", "$1.99" + assert_select "label[for=user_name_0_99]", "$0.99" + assert_select "label[for=user_name_1_99]", "$1.99" + end + + test "collection check boxes correctly builds unique DOM IDs for float values" do + with_collection_check_boxes :user, :name, [1.0, 10], :to_s, :to_s + assert_select "label[for=user_name_1_0]", "1.0" + assert_select "label[for=user_name_10]", "10" + assert_select 'input#user_name_1_0[type=checkbox][value="1.0"]' + assert_select 'input#user_name_10[type=checkbox][value="10"]' end test "collection check boxes generates labels for non-English values correctly" do |