aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r--actionpack/lib/action_controller/metal/live.rb12
-rw-r--r--actionpack/lib/action_controller/test_case.rb16
2 files changed, 23 insertions, 5 deletions
diff --git a/actionpack/lib/action_controller/metal/live.rb b/actionpack/lib/action_controller/metal/live.rb
index d60f1b0d44..43cf9b9723 100644
--- a/actionpack/lib/action_controller/metal/live.rb
+++ b/actionpack/lib/action_controller/metal/live.rb
@@ -177,13 +177,17 @@ module ActionController
end
end
- def commit!
- headers.freeze
+ private
+
+ def finalize_response
super
+ jar = request.cookie_jar
+ # The response can be committed multiple times
+ jar.write self unless jar.committed?
+ jar.commit!
+ headers.freeze
end
- private
-
def build_buffer(response, body)
buf = Live::Buffer.new response
body.each { |part| buf.write part }
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb
index 33a5858766..009f83861d 100644
--- a/actionpack/lib/action_controller/test_case.rb
+++ b/actionpack/lib/action_controller/test_case.rb
@@ -267,6 +267,18 @@ module ActionController
def body
@body ||= super
end
+
+ # Was the response successful?
+ alias_method :success?, :successful?
+
+ # Was the URL not found?
+ alias_method :missing?, :not_found?
+
+ # Were we redirected?
+ alias_method :redirect?, :redirection?
+
+ # Was there a server-side error?
+ alias_method :error?, :server_error?
end
# Methods #destroy and #load! are overridden to avoid calling methods on the
@@ -583,7 +595,9 @@ module ActionController
@controller.process(name)
if cookies = @request.env['action_dispatch.cookies']
- cookies.write(@response)
+ unless cookies.committed?
+ cookies.write(@response)
+ end
end
@response.prepare!