mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
commit
7caea98e18
3 changed files with 27 additions and 5 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
* Ensure unique DOM IDs for collection inputs with float values.
|
||||||
|
Fixes #34974
|
||||||
|
|
||||||
|
*Mark Edmondson*
|
||||||
|
|
||||||
|
|
||||||
## Rails 6.0.0.beta1 (January 18, 2019) ##
|
## Rails 6.0.0.beta1 (January 18, 2019) ##
|
||||||
|
|
||||||
* [Rename npm package](https://github.com/rails/rails/pull/34905) from
|
* [Rename npm package](https://github.com/rails/rails/pull/34905) from
|
||||||
|
|
|
@ -138,7 +138,7 @@ module ActionView
|
||||||
end
|
end
|
||||||
|
|
||||||
def sanitized_value(value)
|
def sanitized_value(value)
|
||||||
value.to_s.gsub(/\s/, "_").gsub(/[^-[[:word:]]]/, "").mb_chars.downcase.to_s
|
value.to_s.gsub(/[\s\.]/, "_").gsub(/[^-[[:word:]]]/, "").mb_chars.downcase.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
def select_content_tag(option_tags, options, html_options)
|
def select_content_tag(option_tags, options, html_options)
|
||||||
|
|
|
@ -48,8 +48,16 @@ class FormCollectionsHelperTest < ActionView::TestCase
|
||||||
|
|
||||||
test "collection radio should sanitize collection values for labels correctly" do
|
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
|
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_0_99]", "$0.99"
|
||||||
assert_select "label[for=user_name_199]", "$1.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
|
end
|
||||||
|
|
||||||
test "collection radio accepts checked item" do
|
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
|
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
|
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_0_99]", "$0.99"
|
||||||
assert_select "label[for=user_name_199]", "$1.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
|
end
|
||||||
|
|
||||||
test "collection check boxes generates labels for non-English values correctly" do
|
test "collection check boxes generates labels for non-English values correctly" do
|
||||||
|
|
Loading…
Reference in a new issue