aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template
diff options
context:
space:
mode:
authorOlek Janiszewski <olek.janiszewski@gmail.com>2013-03-08 18:07:09 +0100
committerOlek Janiszewski <olek.janiszewski@gmail.com>2013-03-08 19:01:32 +0100
commit8e05a6f6380c6ddbef5a0620b30d19dbca7f2f15 (patch)
tree91d3089df0d9679a0a17c0308a83e27545fe20bb /actionpack/test/template
parentdd1d309fa9c158607a35fee2c18b477728811ad8 (diff)
downloadrails-8e05a6f6380c6ddbef5a0620b30d19dbca7f2f15.tar.gz
rails-8e05a6f6380c6ddbef5a0620b30d19dbca7f2f15.tar.bz2
rails-8e05a6f6380c6ddbef5a0620b30d19dbca7f2f15.zip
Fix incorrectly appended square brackets to a multiple select box
If an explicit name has been given and it already ends with "[]" Before: select(:category, [], {}, multiple: true, name: "post[category][]") # => <select name="post[category][][]" ...> After: select(:category, [], {}, multiple: true, name: "post[category][]") # => <select name="post[category][]" ...>
Diffstat (limited to 'actionpack/test/template')
-rw-r--r--actionpack/test/template/form_options_helper_test.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/actionpack/test/template/form_options_helper_test.rb b/actionpack/test/template/form_options_helper_test.rb
index 04cdd068c8..29d63d9653 100644
--- a/actionpack/test/template/form_options_helper_test.rb
+++ b/actionpack/test/template/form_options_helper_test.rb
@@ -575,6 +575,14 @@ class FormOptionsHelperTest < ActionView::TestCase
)
end
+ def test_select_with_multiple_and_with_explicit_name_ending_with_brackets
+ output_buffer = select(:post, :category, [], {include_hidden: false}, multiple: true, name: 'post[category][]')
+ assert_dom_equal(
+ "<select multiple=\"multiple\" id=\"post_category\" name=\"post[category][]\"></select>",
+ output_buffer
+ )
+ end
+
def test_select_with_multiple_and_disabled_to_add_disabled_hidden_input
output_buffer = select(:post, :category, "", {}, :multiple => true, :disabled => true)
assert_dom_equal(