diff --git a/actionpack/test/controller/integration_upload_test.rb b/actionpack/test/controller/integration_upload_test.rb index d579980..63b2301 100644 --- a/actionpack/test/controller/integration_upload_test.rb +++ b/actionpack/test/controller/integration_upload_test.rb @@ -23,6 +23,13 @@ class SessionUploadTest < ActionController::IntegrationTest attr_accessor :last_request_type end + AppWithMiddleware = lambda { |env| + req = Rack::Request.new(env) + req.params # Parse params + app = ActionController::Dispatcher.new + app.call(env) + } + def test_upload_and_read_file with_test_routing do post '/read', :uploaded_data => fixture_file_upload(FILES_DIR + "/hello.txt", "text/plain") @@ -30,6 +37,15 @@ class SessionUploadTest < ActionController::IntegrationTest end end + def test_pass_through_rack_middleware_that_uploads_and_reads_file + @integration_session = ActionController::Integration::Session.new(AppWithMiddleware) + + with_test_routing do + post '/read', :uploaded_data => fixture_file_upload(FILES_DIR + "/hello.txt", "text/plain") + assert_equal "File: Hello", response.body + end + end + # The lint wrapper is used in integration tests # instead of a normal StringIO class InputWrapper = Rack::Lint::InputWrapper @@ -43,6 +59,16 @@ class SessionUploadTest < ActionController::IntegrationTest end end + def test_post_and_pass_through_rack_middleware_that_uploads_with_unrewindable_input + @integration_session = ActionController::Integration::Session.new(AppWithMiddleware) + InputWrapper.any_instance.expects(:rewind).raises(Errno::ESPIPE) + + with_test_routing do + post '/read', :uploaded_data => fixture_file_upload(FILES_DIR + "/hello.txt", "text/plain") + assert_equal "File: Hello", response.body + end + end + def test_post_with_upload_with_params_parsing with_test_routing do params = { :uploaded_data => fixture_file_upload(FILES_DIR + "/mona_lisa.jpg", "image/jpg") }