mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Fix failing cascade exception.
This commit is contained in:
@@ -15,6 +15,7 @@ module ActionDispatch
|
||||
begin
|
||||
response = @app.call(env)
|
||||
|
||||
# TODO: Maybe this should be in the router itself
|
||||
if response[1]['X-Cascade'] == 'pass'
|
||||
raise ActionController::RoutingError, "No route matches [#{env['REQUEST_METHOD']}] #{env['PATH_INFO'].inspect}"
|
||||
end
|
||||
@@ -22,7 +23,7 @@ module ActionDispatch
|
||||
raise exception if env['action_dispatch.show_exceptions'] == false
|
||||
end
|
||||
|
||||
response ? response : render_exception(env, exception)
|
||||
exception ? render_exception(env, exception) : response
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -40,7 +40,7 @@ module ActionDispatch
|
||||
raise exception if env['action_dispatch.show_exceptions'] == false
|
||||
end
|
||||
|
||||
response ? response : render_exception_with_failsafe(env, exception)
|
||||
response || render_exception_with_failsafe(env, exception)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -11,6 +11,8 @@ class DebugExceptionsTest < ActionDispatch::IntegrationTest
|
||||
env['action_dispatch.show_detailed_exceptions'] = @detailed
|
||||
req = ActionDispatch::Request.new(env)
|
||||
case req.path
|
||||
when "/pass"
|
||||
[404, { "X-Cascade" => "pass" }, []]
|
||||
when "/not_found"
|
||||
raise ActionController::UnknownAction
|
||||
when "/runtime_error"
|
||||
@@ -46,6 +48,13 @@ class DebugExceptionsTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
end
|
||||
|
||||
test 'raise an exception on cascade pass' do
|
||||
@app = ProductionApp
|
||||
assert_raise ActionController::RoutingError do
|
||||
get "/pass", {}, {'action_dispatch.show_exceptions' => true}
|
||||
end
|
||||
end
|
||||
|
||||
test "rescue with diagnostics message" do
|
||||
@app = DevelopmentApp
|
||||
|
||||
|
||||
Reference in New Issue
Block a user