diff options
author | Eileen M. Uchitelle <eileencodes@gmail.com> | 2016-09-04 08:13:40 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-04 08:13:40 -0400 |
commit | 10fcf42497a3c3e561b38af38d57cf5cbe8da195 (patch) | |
tree | 97b822f7fe225072be917db8b6e82d5503bcbe4c /actionpack/test/controller | |
parent | ce97dc1abf4d301c8a4aaa7e790088b8d318afd4 (diff) | |
parent | 333f10e32c0b8cbaf4dbaaee3333d21b138a7d4a (diff) | |
download | rails-10fcf42497a3c3e561b38af38d57cf5cbe8da195.tar.gz rails-10fcf42497a3c3e561b38af38d57cf5cbe8da195.tar.bz2 rails-10fcf42497a3c3e561b38af38d57cf5cbe8da195.zip |
Merge pull request #26384 from y-yagi/make_fixture_file_upload_in_integration_test
make `fixture_file_upload` work in integration tests
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r-- | actionpack/test/controller/integration_test.rb | 36 |
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 |