From e3a4eb4b4067ee7d906babd029e60565001f7808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 14 Dec 2011 17:03:35 +0100 Subject: Close the response body on cascade pass, closes #3975. --- actionpack/test/dispatch/debug_exceptions_test.rb | 25 ++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'actionpack/test/dispatch') diff --git a/actionpack/test/dispatch/debug_exceptions_test.rb b/actionpack/test/dispatch/debug_exceptions_test.rb index 6133bfe338..29fc248acc 100644 --- a/actionpack/test/dispatch/debug_exceptions_test.rb +++ b/actionpack/test/dispatch/debug_exceptions_test.rb @@ -3,8 +3,18 @@ require 'abstract_unit' class DebugExceptionsTest < ActionDispatch::IntegrationTest class Boomer + attr_accessor :closed + def initialize(detailed = false) @detailed = detailed + @closed = false + end + + def each + end + + def close + @closed = true end def call(env) @@ -12,7 +22,7 @@ class DebugExceptionsTest < ActionDispatch::IntegrationTest req = ActionDispatch::Request.new(env) case req.path when "/pass" - [404, { "X-Cascade" => "pass" }, []] + [404, { "X-Cascade" => "pass" }, self] when "/not_found" raise ActionController::UnknownAction when "/runtime_error" @@ -31,8 +41,8 @@ class DebugExceptionsTest < ActionDispatch::IntegrationTest end end - ProductionApp = ActionDispatch::DebugExceptions.new((Boomer.new(false))) - DevelopmentApp = ActionDispatch::DebugExceptions.new((Boomer.new(true))) + ProductionApp = ActionDispatch::DebugExceptions.new(Boomer.new(false)) + DevelopmentApp = ActionDispatch::DebugExceptions.new(Boomer.new(true)) test 'skip diagnosis if not showing detailed exceptions' do @app = ProductionApp @@ -55,6 +65,15 @@ class DebugExceptionsTest < ActionDispatch::IntegrationTest end end + test 'closes the response body on cascade pass' do + boomer = Boomer.new(false) + @app = ActionDispatch::DebugExceptions.new(boomer) + assert_raise ActionController::RoutingError do + get "/pass", {}, {'action_dispatch.show_exceptions' => true} + end + assert boomer.closed, "Expected to close the response body" + end + test "rescue with diagnostics message" do @app = DevelopmentApp -- cgit v1.2.3