From f65fd25f0491919ef9db6e79be43f5d6f518374a Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 8 Jul 2015 16:23:32 -0700 Subject: request objects are no longer recycled Instead of trying to manually clear out a request object, lets just allocate a new one. The rack ENV is reused and cleaned (still), but the request object is not. --- actionpack/lib/action_controller/test_case.rb | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index c63dde4ff6..6095f1b95e 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -73,15 +73,6 @@ module ActionController @env['CONTENT_LENGTH'] = data.length.to_s @env['rack.input'] = StringIO.new(data) end - - def recycle! - @formats = nil - @env.delete_if { |k, v| k =~ /^(action_dispatch|rack)\.request/ } - @env.delete_if { |k, v| k =~ /^action_dispatch\.rescue/ } - @method = @request_method = nil - @fullpath = @ip = @remote_ip = @protocol = nil - @env['action_dispatch.request.query_parameters'] = {} - end end class TestResponse < ActionDispatch::TestResponse @@ -451,7 +442,7 @@ module ActionController @request.env['HTTP_COOKIE'] = cookies.to_header @request.env['action_dispatch.cookies'] = nil - @request.recycle! + @request = TestRequest.new scrub_env!(@request.env), @request.session @response = build_response @response_klass @response.request = @request @controller.recycle! @@ -546,6 +537,13 @@ module ActionController private + def scrub_env!(env) + env.delete_if { |k, v| k =~ /^(action_dispatch|rack)\.request/ } + env.delete_if { |k, v| k =~ /^action_dispatch\.rescue/ } + env['action_dispatch.request.query_parameters'] = {} + env + end + def process_with_kwargs(http_method, action, *args) if kwarg_request?(args) args.first.merge!(method: http_method) -- cgit v1.2.3