aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorTim Vandecasteele <tim.vandecasteele@vasco.com>2012-06-21 10:16:28 +0200
committerTim Vandecasteele <tim.vandecasteele@vasco.com>2012-06-22 09:27:41 +0200
commit8471edc6725aa905dc9f7b800438acb255b1512e (patch)
tree7331a13d02d56c3fd17f28daf545644fdc586b0f /actionpack
parent1bb2f5a8316c3e94b47b9cfb8fa519e1b1238869 (diff)
downloadrails-8471edc6725aa905dc9f7b800438acb255b1512e.tar.gz
rails-8471edc6725aa905dc9f7b800438acb255b1512e.tar.bz2
rails-8471edc6725aa905dc9f7b800438acb255b1512e.zip
Don't paramify ActionDispatch::Http::UploadedFile in tests
To test uploading a file without using fixture_file_upload, a posted ActionDispatch::Http::UploadedFile should not be paramified (just like Rack::Test::UploadedFile). (Rack::Test::UploadedFile and ActionDispatch::Http::UploadedFile don't share the same API, tempfile is not accessible on Rack::Test::UploadedFile as discussed in https://github.com/brynary/rack-test/issues/30)
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_controller/test_case.rb2
-rw-r--r--actionpack/test/controller/test_case_test.rb7
2 files changed, 8 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb
index 028a8d3fba..2fcff8a675 100644
--- a/actionpack/lib/action_controller/test_case.rb
+++ b/actionpack/lib/action_controller/test_case.rb
@@ -450,7 +450,7 @@ module ActionController
Hash[hash_or_array_or_value.map{|key, value| [key, paramify_values(value)] }]
when Array
hash_or_array_or_value.map {|i| paramify_values(i)}
- when Rack::Test::UploadedFile
+ when Rack::Test::UploadedFile, ActionDispatch::Http::UploadedFile
hash_or_array_or_value
else
hash_or_array_or_value.to_param
diff --git a/actionpack/test/controller/test_case_test.rb b/actionpack/test/controller/test_case_test.rb
index 0d6d303b51..49137946fe 100644
--- a/actionpack/test/controller/test_case_test.rb
+++ b/actionpack/test/controller/test_case_test.rb
@@ -813,6 +813,13 @@ XML
assert_equal '159528', @response.body
end
+ def test_action_dispatch_uploaded_file_upload
+ filename = 'mona_lisa.jpg'
+ path = "#{FILES_DIR}/#{filename}"
+ post :test_file_upload, :file => ActionDispatch::Http::UploadedFile.new(:filename => path, :type => "image/jpg", :tempfile => File.open(path))
+ assert_equal '159528', @response.body
+ end
+
def test_test_uploaded_file_exception_when_file_doesnt_exist
assert_raise(RuntimeError) { Rack::Test::UploadedFile.new('non_existent_file') }
end