diff options
author | Yehuda Katz <wycats@gmail.com> | 2009-01-13 14:24:10 -0800 |
---|---|---|
committer | Yehuda Katz <wycats@gmail.com> | 2009-01-13 14:24:14 -0800 |
commit | f65333a4cfcdc73b2f2e51fc4353370ab308135e (patch) | |
tree | 77a2ca3af3a54bc5412385230dd57b0641bba945 /actionpack/test/controller/request/url_encoded_params_parsing_test.rb | |
parent | 0932b012fae2ff21214f610a0fd78a55ae4e2420 (diff) | |
parent | 1adc1496f9152c893e1f08abcb1e5e7272829899 (diff) | |
download | rails-f65333a4cfcdc73b2f2e51fc4353370ab308135e.tar.gz rails-f65333a4cfcdc73b2f2e51fc4353370ab308135e.tar.bz2 rails-f65333a4cfcdc73b2f2e51fc4353370ab308135e.zip |
Sync 'rails/rails/master'
Diffstat (limited to 'actionpack/test/controller/request/url_encoded_params_parsing_test.rb')
-rw-r--r-- | actionpack/test/controller/request/url_encoded_params_parsing_test.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/actionpack/test/controller/request/url_encoded_params_parsing_test.rb b/actionpack/test/controller/request/url_encoded_params_parsing_test.rb index 26a4538ca6..b162796e5b 100644 --- a/actionpack/test/controller/request/url_encoded_params_parsing_test.rb +++ b/actionpack/test/controller/request/url_encoded_params_parsing_test.rb @@ -150,8 +150,45 @@ class UrlEncodedParamsParsingTest < ActionController::IntegrationTest assert_parses expected, query end + test "passes through rack middleware and parses params" do + with_muck_middleware do + assert_parses({ "a" => { "b" => "c" } }, "a[b]=c") + end + end + + # The lint wrapper is used in integration tests + # instead of a normal StringIO class + InputWrapper = Rack::Lint::InputWrapper + + test "passes through rack middleware and parses params with unwindable input" do + InputWrapper.any_instance.stubs(:rewind).raises(Errno::ESPIPE) + with_muck_middleware do + assert_parses({ "a" => { "b" => "c" } }, "a[b]=c") + end + end private + class MuckMiddleware + def initialize(app) + @app = app + end + + def call(env) + req = Rack::Request.new(env) + req.params # Parse params + @app.call(env) + end + end + + def with_muck_middleware + original_middleware = ActionController::Dispatcher.middleware + middleware = original_middleware.dup + middleware.use MuckMiddleware + ActionController::Dispatcher.middleware = middleware + yield + ActionController::Dispatcher.middleware = original_middleware + end + def with_test_routing with_routing do |set| set.draw do |map| |