diff options
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/actionable_exceptions.rb | 4 | ||||
-rw-r--r-- | actionpack/test/dispatch/actionable_exceptions_test.rb | 10 |
2 files changed, 12 insertions, 2 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/actionable_exceptions.rb b/actionpack/lib/action_dispatch/middleware/actionable_exceptions.rb index 059fcdcfd4..e94cc46603 100644 --- a/actionpack/lib/action_dispatch/middleware/actionable_exceptions.rb +++ b/actionpack/lib/action_dispatch/middleware/actionable_exceptions.rb @@ -16,9 +16,9 @@ module ActionDispatch request = ActionDispatch::Request.new(env) return @app.call(env) unless actionable_request?(request) - ActiveSupport::ActionableError.dispatch(request.params["error"], request.params["action"]) + ActiveSupport::ActionableError.dispatch(request.params[:error].to_s.safe_constantize, request.params[:action]) - redirect_to request.params["location"] + redirect_to request.params[:location] end private diff --git a/actionpack/test/dispatch/actionable_exceptions_test.rb b/actionpack/test/dispatch/actionable_exceptions_test.rb index ae382e201e..9215a91e9c 100644 --- a/actionpack/test/dispatch/actionable_exceptions_test.rb +++ b/actionpack/test/dispatch/actionable_exceptions_test.rb @@ -67,4 +67,14 @@ class ActionableExceptionsTest < ActionDispatch::IntegrationTest } end end + + test "cannot dispatch Inexistent errors" do + assert_raise ActiveSupport::ActionableError::NonActionable do + post ActionDispatch::ActionableExceptions.endpoint, params: { + error: "", + action: "Inexistent action", + location: "/", + } + end + end end |