Arrays sent via multipart posts are converted to strings #1032 [dj@omelia.org]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1397 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Jamis Buck 2005-06-10 12:21:25 +00:00
parent 6cff8487ed
commit f6ec9e3d66
3 changed files with 8 additions and 1 deletions

View File

@ -1,5 +1,7 @@
*SVN* *SVN*
* Arrays sent via multipart posts are converted to strings #1032 [dj@omelia.org]
* render(:layout => true) is a synonym for render(:layout => nil) * render(:layout => true) is a synonym for render(:layout => nil)
* Make sure the benchmarking render method always returns the output of the render. * Make sure the benchmarking render method always returns the output of the render.

View File

@ -69,7 +69,7 @@ class CGIMethods #:nodoc:
# Value as part of a multipart request # Value as part of a multipart request
value.read value.read
elsif value.class == Array elsif value.class == Array
value value.collect { | e | e.respond_to?(:read) ? e.read : e }
else else
# Standard value (not a multipart request) # Standard value (not a multipart request)
value.to_s value.to_s

View File

@ -94,12 +94,16 @@ class CGITest < Test::Unit::TestCase
input = { input = {
"something" => [ StringIO.new("") ], "something" => [ StringIO.new("") ],
"array_of_stringios" => [[ StringIO.new("One"), StringIO.new("Two") ]],
"mixed_types_array" => [[ StringIO.new("Three"), "NotStringIO" ]],
"products[string]" => [ StringIO.new("Apple Computer") ], "products[string]" => [ StringIO.new("Apple Computer") ],
"products[file]" => [ mock_file ] "products[file]" => [ mock_file ]
} }
expected_output = { expected_output = {
"something" => "", "something" => "",
"array_of_stringios" => ["One", "Two"],
"mixed_types_array" => [ "Three", "NotStringIO" ],
"products" => { "products" => {
"string" => "Apple Computer", "string" => "Apple Computer",
"file" => mock_file "file" => mock_file
@ -169,3 +173,4 @@ class CGITest < Test::Unit::TestCase
assert_equal expected, CGIMethods.parse_request_parameters(input) assert_equal expected, CGIMethods.parse_request_parameters(input)
end end
end end