aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authoryuuji.yaginuma <yuuji.yaginuma@gmail.com>2016-09-03 15:17:05 +0900
committeryuuji.yaginuma <yuuji.yaginuma@gmail.com>2016-09-04 11:37:43 +0900
commit333f10e32c0b8cbaf4dbaaee3333d21b138a7d4a (patch)
treed0464284d513fb8af1737ecf2eeb0a7d7f835d0f /actionpack/test
parent55c5dffd9f2220507ff1a7635c00a81577a8a391 (diff)
downloadrails-333f10e32c0b8cbaf4dbaaee3333d21b138a7d4a.tar.gz
rails-333f10e32c0b8cbaf4dbaaee3333d21b138a7d4a.tar.bz2
rails-333f10e32c0b8cbaf4dbaaee3333d21b138a7d4a.zip
make `fixture_file_upload` work in integration tests
Currently, `fixture_file_upload` does not work in integration test. Because, `TestProcess` module has been include in `Session` class, but `fixture_path` can not get from `Session` class. Modify to include `TestProcess` in `IntegrationTest` class in order to get correct value of `fixture_path`.
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/controller/integration_test.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb
index 9044eff801..d3bc77d3ef 100644
--- a/actionpack/test/controller/integration_test.rb
+++ b/actionpack/test/controller/integration_test.rb
@@ -1281,3 +1281,39 @@ class IntegrationRequestEncodersTest < ActionDispatch::IntegrationTest
end
end
end
+
+class IntegrationFileUploadTest < ActionDispatch::IntegrationTest
+ class IntegrationController < ActionController::Base
+ def test_file_upload
+ render plain: params[:file].size
+ end
+ end
+
+ def self.routes
+ @routes ||= ActionDispatch::Routing::RouteSet.new
+ end
+
+ def self.call(env)
+ routes.call(env)
+ end
+
+ def app
+ self.class
+ end
+
+ def self.fixture_path
+ File.dirname(__FILE__) + "/../fixtures/multipart"
+ end
+
+ routes.draw do
+ post "test_file_upload", to: "integration_file_upload_test/integration#test_file_upload"
+ end
+
+ def test_fixture_file_upload
+ post "/test_file_upload",
+ params: {
+ file: fixture_file_upload("/mona_lisa.jpg", "image/jpg")
+ }
+ assert_equal "159528", @response.body
+ end
+end