diff options
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/actionable_exceptions.rb | 2 | ||||
-rw-r--r-- | actionpack/test/dispatch/actionable_exceptions_test.rb | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/actionable_exceptions.rb b/actionpack/lib/action_dispatch/middleware/actionable_exceptions.rb index f76ea7c2e2..059fcdcfd4 100644 --- a/actionpack/lib/action_dispatch/middleware/actionable_exceptions.rb +++ b/actionpack/lib/action_dispatch/middleware/actionable_exceptions.rb @@ -23,7 +23,7 @@ module ActionDispatch private def actionable_request?(request) - request.post? && request.path == endpoint + request.show_exceptions? && request.post? && request.path == endpoint end def redirect_to(location) diff --git a/actionpack/test/dispatch/actionable_exceptions_test.rb b/actionpack/test/dispatch/actionable_exceptions_test.rb index 46979ed878..ae382e201e 100644 --- a/actionpack/test/dispatch/actionable_exceptions_test.rb +++ b/actionpack/test/dispatch/actionable_exceptions_test.rb @@ -38,6 +38,16 @@ class ActionableExceptionsTest < ActionDispatch::IntegrationTest assert_equal "/", response.headers["Location"] end + test "cannot dispatch errors if not allowed" do + post ActionDispatch::ActionableExceptions.endpoint, params: { + error: ActionError.name, + action: "Successful action", + location: "/", + }, headers: { "action_dispatch.show_exceptions" => false } + + assert_empty Actions + end + test "dispatched action can fail" do assert_raise RuntimeError do post ActionDispatch::ActionableExceptions.endpoint, params: { |