提交 fcdcd9b9 编写于 作者: J Jamis Buck

Hashes sent via multipart post should be converted to strings #1032 [me@julik.nl]


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1664 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 cf9c991d
...@@ -125,7 +125,7 @@ ...@@ -125,7 +125,7 @@
* Add assertions with friendly messages to TestCase#process to ensure that @controller, @request, and @response are set. #1367 * Add assertions with friendly messages to TestCase#process to ensure that @controller, @request, and @response are set. #1367
* Arrays sent via multipart posts are converted to strings #1032 [dj@omelia.org] * Arrays, hashes sent via multipart posts are converted to strings #1032 [dj@omelia.org, me@julik.nl]
* render(:layout => true) is a synonym for render(:layout => nil) * render(:layout => true) is a synonym for render(:layout => nil)
......
...@@ -70,7 +70,7 @@ def CGIMethods.get_typed_value(value) ...@@ -70,7 +70,7 @@ def CGIMethods.get_typed_value(value)
# 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.collect { | e | e.respond_to?(:read) ? e.read : e } value.collect { |v| CGIMethods.get_typed_value(v) }
else else
# Standard value (not a multipart request) # Standard value (not a multipart request)
value.to_s value.to_s
......
$:.unshift File.dirname(__FILE__) + "/../../lib"
require 'test/unit' require 'test/unit'
require 'action_controller/cgi_ext/cgi_methods' require 'action_controller/cgi_ext/cgi_methods'
...@@ -112,6 +113,7 @@ def test_parse_params_from_multipart_upload ...@@ -112,6 +113,7 @@ def test_parse_params_from_multipart_upload
"something" => [ StringIO.new("") ], "something" => [ StringIO.new("") ],
"array_of_stringios" => [[ StringIO.new("One"), StringIO.new("Two") ]], "array_of_stringios" => [[ StringIO.new("One"), StringIO.new("Two") ]],
"mixed_types_array" => [[ StringIO.new("Three"), "NotStringIO" ]], "mixed_types_array" => [[ StringIO.new("Three"), "NotStringIO" ]],
"mixed_types_as_checkboxes[strings][nested]" => [[ mock_file, "String", StringIO.new("StringIO")]],
"products[string]" => [ StringIO.new("Apple Computer") ], "products[string]" => [ StringIO.new("Apple Computer") ],
"products[file]" => [ mock_file ] "products[file]" => [ mock_file ]
} }
...@@ -120,6 +122,11 @@ def test_parse_params_from_multipart_upload ...@@ -120,6 +122,11 @@ def test_parse_params_from_multipart_upload
"something" => "", "something" => "",
"array_of_stringios" => ["One", "Two"], "array_of_stringios" => ["One", "Two"],
"mixed_types_array" => [ "Three", "NotStringIO" ], "mixed_types_array" => [ "Three", "NotStringIO" ],
"mixed_types_as_checkboxes" => {
"strings"=> {
"nested"=>[ mock_file, "String", "StringIO" ]
},
},
"products" => { "products" => {
"string" => "Apple Computer", "string" => "Apple Computer",
"file" => mock_file "file" => mock_file
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册