aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorRyan McGeary <ryan@mcgeary.org>2013-04-05 14:51:15 -0400
committerRyan McGeary <ryan@mcgeary.org>2013-04-05 15:32:56 -0400
commit48dc5192eff45fce5ce39c41cdc3188be97ca614 (patch)
treee839649edb175e2da4ca3ac1e8fcc980e16c0978 /actionpack/test
parentd25e0c6f6a2764fb2605dc216e5c4b26a74f7e97 (diff)
downloadrails-48dc5192eff45fce5ce39c41cdc3188be97ca614.tar.gz
rails-48dc5192eff45fce5ce39c41cdc3188be97ca614.tar.bz2
rails-48dc5192eff45fce5ce39c41cdc3188be97ca614.zip
Fix explicit names on multiple file fields
If a file field tag is passed the multiple option, it is turned into an array field (appending "[]"), but if the file field is passed an explicit name as an option, leave the name alone (do not append "[]"). Fixes #9830
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/template/form_helper_test.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb
index dff0b8bdc2..1ff320224d 100644
--- a/actionpack/test/template/form_helper_test.rb
+++ b/actionpack/test/template/form_helper_test.rb
@@ -361,6 +361,16 @@ class FormHelperTest < ActionView::TestCase
assert_dom_equal expected, file_field("user", "avatar")
end
+ def test_file_field_with_multiple_behavior
+ expected = '<input id="import_file" multiple="multiple" name="import[file][]" type="file" />'
+ assert_dom_equal expected, file_field("import", "file", :multiple => true)
+ end
+
+ def test_file_field_with_multiple_behavior_and_explicit_name
+ expected = '<input id="import_file" multiple="multiple" name="custom" type="file" />'
+ assert_dom_equal expected, file_field("import", "file", :multiple => true, :name => "custom")
+ end
+
def test_hidden_field
assert_dom_equal(
'<input id="post_title" name="post[title]" type="hidden" value="Hello World" />',