mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #29984 from colorfulfool/form-helpers-unicode-sanitization
Allow non-English values for collection_radio_buttons
This commit is contained in:
commit
5fd50c387b
2 changed files with 15 additions and 1 deletions
|
@ -138,7 +138,7 @@ module ActionView
|
|||
end
|
||||
|
||||
def sanitized_value(value)
|
||||
value.to_s.gsub(/\s/, "_").gsub(/[^-\w]/, "").downcase
|
||||
value.to_s.gsub(/\s/, "_").gsub(/[^-[[:word:]]]/, "").mb_chars.downcase.to_s
|
||||
end
|
||||
|
||||
def select_content_tag(option_tags, options, html_options)
|
||||
|
|
|
@ -39,6 +39,13 @@ class FormCollectionsHelperTest < ActionView::TestCase
|
|||
assert_select "label[for=user_active_no]", "No"
|
||||
end
|
||||
|
||||
test "collection radio generates labels for non-English values correctly" do
|
||||
with_collection_radio_buttons :user, :title, ["Господин", "Госпожа"], :to_s, :to_s
|
||||
|
||||
assert_select "input[type=radio]#user_title_господин"
|
||||
assert_select "label[for=user_title_господин]", "Господин"
|
||||
end
|
||||
|
||||
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"
|
||||
|
@ -299,6 +306,13 @@ class FormCollectionsHelperTest < ActionView::TestCase
|
|||
assert_select "label[for=user_name_199]", "$1.99"
|
||||
end
|
||||
|
||||
test "collection check boxes generates labels for non-English values correctly" do
|
||||
with_collection_check_boxes :user, :title, ["Господин", "Госпожа"], :to_s, :to_s
|
||||
|
||||
assert_select "input[type=checkbox]#user_title_господин"
|
||||
assert_select "label[for=user_title_господин]", "Господин"
|
||||
end
|
||||
|
||||
test "collection check boxes accepts html options as the last element of array" do
|
||||
collection = [[1, "Category 1", { class: "foo" }], [2, "Category 2", { class: "bar" }]]
|
||||
with_collection_check_boxes :user, :active, collection, :first, :second
|
||||
|
|
Loading…
Reference in a new issue