aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2012-09-29 07:44:11 -0700
committerRafael Mendonça França <rafaelmfranca@gmail.com>2012-09-29 07:44:11 -0700
commitc2a7084a2df375e2a608767c6079a8d82a783620 (patch)
tree5664c84bd48af9f73413640191b88381e5e5dab6
parente1a10b15c20dc98f19b2a1b9d984d19bedfddcfa (diff)
parentc53e5def08f7a289a92a8e5f79dcd7caa5c3a2fb (diff)
downloadrails-c2a7084a2df375e2a608767c6079a8d82a783620.tar.gz
rails-c2a7084a2df375e2a608767c6079a8d82a783620.tar.bz2
rails-c2a7084a2df375e2a608767c6079a8d82a783620.zip
Merge pull request #7786 from yabawock/3-2-stable
Backport "Don't paramify ActionDispatch::Http::UploadedFile in tests"
-rw-r--r--actionpack/CHANGELOG.md6
-rw-r--r--actionpack/lib/action_controller/test_case.rb2
-rw-r--r--actionpack/test/controller/test_test.rb7
3 files changed, 14 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md
index e86008d26c..09e9188f6f 100644
--- a/actionpack/CHANGELOG.md
+++ b/actionpack/CHANGELOG.md
@@ -46,6 +46,12 @@
*Jeremy Kemper & Erich Menge*
+* Handle `ActionDispatch::Http::UploadedFile` like `Rack::Test::UploadedFile`, don't call to_param on it. Since
+ `Rack::Test::UploadedFile` isn't API compatible this is needed to test file uploads that rely on `tempfile`
+ being available.
+
+ *Tim Vandecasteele*
+
## Rails 3.2.8 (Aug 9, 2012) ##
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb
index 05e3cd40b5..717e4043bb 100644
--- a/actionpack/lib/action_controller/test_case.rb
+++ b/actionpack/lib/action_controller/test_case.rb
@@ -422,7 +422,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_test.rb b/actionpack/test/controller/test_test.rb
index 6a5843f9d7..677a933ccb 100644
--- a/actionpack/test/controller/test_test.rb
+++ b/actionpack/test/controller/test_test.rb
@@ -766,6 +766,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