aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2015-07-08 11:16:44 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2015-07-08 11:16:44 -0700
commit2b5d309aeb68e9d30d6e090a9c603efe780e50c7 (patch)
tree5b9c3e9231fa9570470b01af4c3152be8e0858bf
parentc2b5aa041b04e65475dd3ebb9f33a68b26e25895 (diff)
downloadrails-2b5d309aeb68e9d30d6e090a9c603efe780e50c7.tar.gz
rails-2b5d309aeb68e9d30d6e090a9c603efe780e50c7.tar.bz2
rails-2b5d309aeb68e9d30d6e090a9c603efe780e50c7.zip
allocate new responses rather than recycling them
There is no reason to "recycle" response objects when we can just allocate a new one.
-rw-r--r--actionpack/lib/action_controller/test_case.rb17
1 files changed, 5 insertions, 12 deletions
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb
index 9a7da54c95..5489a0fde0 100644
--- a/actionpack/lib/action_controller/test_case.rb
+++ b/actionpack/lib/action_controller/test_case.rb
@@ -75,17 +75,9 @@ module ActionController
end
class TestResponse < ActionDispatch::TestResponse
- def recycle!
- initialize
- end
end
class LiveTestResponse < Live::Response
- def recycle!
- @body = nil
- initialize
- end
-
def body
@body ||= super
end
@@ -450,7 +442,8 @@ module ActionController
@request.env['action_dispatch.cookies'] = nil
@request.recycle!
- @response.recycle!
+ @response = build_response @response_klass
+ @response.request = @request
@controller.recycle!
@request.env['REQUEST_METHOD'] = http_method
@@ -504,11 +497,11 @@ module ActionController
def setup_controller_request_and_response
@controller = nil unless defined? @controller
- response_klass = TestResponse
+ @response_klass = TestResponse
if klass = self.class.controller_class
if klass < ActionController::Live
- response_klass = LiveTestResponse
+ @response_klass = LiveTestResponse
end
unless @controller
begin
@@ -521,7 +514,7 @@ module ActionController
@request = build_request
@request.env["rack.request.cookie_hash"] = {}.with_indifferent_access
- @response = build_response response_klass
+ @response = build_response @response_klass
@response.request = @request
if @controller