aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/request/multipart_params_parsing_test.rb
diff options
context:
space:
mode:
authorAditya Chadha <aditya@sublucid.com>2009-05-02 18:32:45 -0400
committerAditya Chadha <aditya@sublucid.com>2009-05-02 18:32:45 -0400
commit7a17ad3f2b89baea94450af8e63a640ace570938 (patch)
tree89cd60c05d4a812b3c8636373a05689b1df5bf75 /actionpack/test/dispatch/request/multipart_params_parsing_test.rb
parent5469a0be1a517a0c2d8ee553b704df4e6f7df306 (diff)
parent1b32f882091ed7744654f74238f3f3b1ba6701ae (diff)
downloadrails-7a17ad3f2b89baea94450af8e63a640ace570938.tar.gz
rails-7a17ad3f2b89baea94450af8e63a640ace570938.tar.bz2
rails-7a17ad3f2b89baea94450af8e63a640ace570938.zip
Merge branch 'master' of git@github.com:lifo/docrails
Diffstat (limited to 'actionpack/test/dispatch/request/multipart_params_parsing_test.rb')
-rw-r--r--actionpack/test/dispatch/request/multipart_params_parsing_test.rb64
1 files changed, 1 insertions, 63 deletions
diff --git a/actionpack/test/dispatch/request/multipart_params_parsing_test.rb b/actionpack/test/dispatch/request/multipart_params_parsing_test.rb
index 88b81dc493..9e008a9ae8 100644
--- a/actionpack/test/dispatch/request/multipart_params_parsing_test.rb
+++ b/actionpack/test/dispatch/request/multipart_params_parsing_test.rb
@@ -94,9 +94,8 @@ class MultipartParamsParsingTest < ActionController::IntegrationTest
assert_equal %w(files foo), params.keys.sort
assert_equal 'bar', params['foo']
- # Ruby CGI doesn't handle multipart/mixed for us.
+ # Rack doesn't handle multipart/mixed for us.
files = params['files']
- assert_kind_of String, files
files.force_encoding('ASCII-8BIT') if files.respond_to?(:force_encoding)
assert_equal 19756, files.size
end
@@ -133,46 +132,6 @@ class MultipartParamsParsingTest < ActionController::IntegrationTest
end
end
- # The lint wrapper is used in integration tests
- # instead of a normal StringIO class
- InputWrapper = Rack::Lint::InputWrapper
-
- test "parses unwindable stream" do
- InputWrapper.any_instance.stubs(:rewind).raises(Errno::ESPIPE)
- params = parse_multipart('large_text_file')
- assert_equal %w(file foo), params.keys.sort
- assert_equal 'bar', params['foo']
- end
-
- test "uploads and reads file with unwindable input" do
- InputWrapper.any_instance.stubs(:rewind).raises(Errno::ESPIPE)
-
- with_test_routing do
- post '/read', :uploaded_data => fixture_file_upload(FIXTURE_PATH + "/hello.txt", "text/plain")
- assert_equal "File: Hello", response.body
- end
- end
-
- test "passes through rack middleware and uploads file" do
- with_muck_middleware do
- with_test_routing do
- post '/read', :uploaded_data => fixture_file_upload(FIXTURE_PATH + "/hello.txt", "text/plain")
- assert_equal "File: Hello", response.body
- end
- end
- end
-
- test "passes through rack middleware and uploads file with unwindable input" do
- InputWrapper.any_instance.stubs(:rewind).raises(Errno::ESPIPE)
-
- with_muck_middleware do
- with_test_routing do
- post '/read', :uploaded_data => fixture_file_upload(FIXTURE_PATH + "/hello.txt", "text/plain")
- assert_equal "File: Hello", response.body
- end
- end
- end
-
private
def fixture(name)
File.open(File.join(FIXTURE_PATH, name), 'rb') do |file|
@@ -199,25 +158,4 @@ class MultipartParamsParsingTest < ActionController::IntegrationTest
yield
end
end
-
- class MuckMiddleware
- def initialize(app)
- @app = app
- end
-
- def call(env)
- env['rack.input'].read
- env['rack.input'].rewind
- @app.call(env)
- end
- end
-
- def with_muck_middleware
- original_middleware = ActionController::Dispatcher.middleware
- middleware = original_middleware.dup
- middleware.insert_after ActionDispatch::RewindableInput, MuckMiddleware
- ActionController::Dispatcher.middleware = middleware
- yield
- ActionController::Dispatcher.middleware = original_middleware
- end
end