aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/cgi_test.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2006-11-09 18:52:19 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2006-11-09 18:52:19 +0000
commit0342393b30e46a5a6433420e9e1b192ec65f8a11 (patch)
tree969fe07b84e16620dab707b2cadf285ac2390b7b /actionpack/test/controller/cgi_test.rb
parentd3100ec85500b970f94819a749f071eeb74dc206 (diff)
downloadrails-0342393b30e46a5a6433420e9e1b192ec65f8a11.tar.gz
rails-0342393b30e46a5a6433420e9e1b192ec65f8a11.tar.bz2
rails-0342393b30e46a5a6433420e9e1b192ec65f8a11.zip
Multipart form values may have a content type without being treated as uploaded files if they do not provide a filename. Closes #6401.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5473 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/controller/cgi_test.rb')
-rwxr-xr-xactionpack/test/controller/cgi_test.rb13
1 files changed, 8 insertions, 5 deletions
diff --git a/actionpack/test/controller/cgi_test.rb b/actionpack/test/controller/cgi_test.rb
index 2d21e0ae97..1d2888ad89 100755
--- a/actionpack/test/controller/cgi_test.rb
+++ b/actionpack/test/controller/cgi_test.rb
@@ -155,9 +155,10 @@ class CGITest < Test::Unit::TestCase
end
def test_parse_params_from_multipart_upload
- mockup = Struct.new(:content_type, :original_filename)
+ mockup = Struct.new(:content_type, :original_filename, :read, :rewind)
file = mockup.new('img/jpeg', 'foo.jpg')
ie_file = mockup.new('img/jpeg', 'c:\\Documents and Settings\\foo\\Desktop\\bar.jpg')
+ non_file_text_part = mockup.new('text/plain', '', 'abc')
input = {
"something" => [ StringIO.new("") ],
@@ -168,9 +169,10 @@ class CGITest < Test::Unit::TestCase
"products[string]" => [ StringIO.new("Apple Computer") ],
"products[file]" => [ file ],
"ie_products[string]" => [ StringIO.new("Microsoft") ],
- "ie_products[file]" => [ ie_file ]
+ "ie_products[file]" => [ ie_file ],
+ "text_part" => [non_file_text_part]
}
-
+
expected_output = {
"something" => "",
"array_of_stringios" => ["One", "Two"],
@@ -192,7 +194,8 @@ class CGITest < Test::Unit::TestCase
"ie_products" => {
"string" => "Microsoft",
"file" => ie_file
- }
+ },
+ "text_part" => "abc"
}
params = CGIMethods.parse_request_parameters(input)
@@ -338,7 +341,7 @@ class MultipartCGITest < Test::Unit::TestCase
assert_equal 'bar', params['foo']
# Ruby CGI doesn't handle multipart/mixed for us.
- assert_kind_of StringIO, params['files']
+ assert_kind_of String, params['files']
assert_equal 19756, params['files'].size
end