diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2015-09-18 13:03:07 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2015-09-18 13:03:07 -0700 |
commit | a1ced8b52ce60d0634e65aa36cb89f015f9f543d (patch) | |
tree | 22379c807f1040ba345c85bf65f07e93fb47a2b2 /actionpack/test | |
parent | b93c226d19615fe504f9e12d6c0ee2d70683e5fa (diff) | |
download | rails-a1ced8b52ce60d0634e65aa36cb89f015f9f543d.tar.gz rails-a1ced8b52ce60d0634e65aa36cb89f015f9f543d.tar.bz2 rails-a1ced8b52ce60d0634e65aa36cb89f015f9f543d.zip |
do not instantiate a param parser middleware
we don't actually need a param parser middleware instance since the
request object will take care of parsing parameters for us. For now,
we'll just configure the parameter parsers on the request in this class.
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/webservice_test.rb | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/actionpack/test/controller/webservice_test.rb b/actionpack/test/controller/webservice_test.rb index b26f037c36..8b37c9599e 100644 --- a/actionpack/test/controller/webservice_test.rb +++ b/actionpack/test/controller/webservice_test.rb @@ -97,24 +97,28 @@ class WebServiceTest < ActionDispatch::IntegrationTest end def test_parsing_json_doesnot_rescue_exception - with_test_route_set do - with_params_parsers Mime::JSON => Proc.new { |data| raise Interrupt } do - assert_raises(Interrupt) do - post "/", - params: '{"title":"JSON"}}', - headers: { 'CONTENT_TYPE' => 'application/json' } - end + req = Class.new(ActionDispatch::Request) do + def params_parsers + { Mime::JSON => Proc.new { |data| raise Interrupt } } end + + def content_length; get_header('rack.input').length; end + end.new({ 'rack.input' => StringIO.new('{"title":"JSON"}}'), 'CONTENT_TYPE' => 'application/json' }) + + assert_raises(Interrupt) do + req.request_parameters end end private def with_params_parsers(parsers = {}) old_session = @integration_session - @app = ActionDispatch::ParamsParser.new(app.routes, parsers) + original_parsers = ActionDispatch::Request.parameter_parsers + ActionDispatch::Request.parameter_parsers = original_parsers.merge parsers reset! yield ensure + ActionDispatch::Request.parameter_parsers = original_parsers @integration_session = old_session end |