diff options
author | Genadi Samokovarov <gsamokovarov@gmail.com> | 2019-02-06 08:55:23 +0200 |
---|---|---|
committer | Genadi Samokovarov <gsamokovarov@gmail.com> | 2019-04-19 14:15:41 +0900 |
commit | 769f73cc18c58021d49a3b93f1747568fe42ee5c (patch) | |
tree | 7ea62c89d042c3a69f50d151eb45f3135bbe6353 | |
parent | 1820b197050251902e1ea6e9334181a78e4c1499 (diff) | |
download | rails-769f73cc18c58021d49a3b93f1747568fe42ee5c.tar.gz rails-769f73cc18c58021d49a3b93f1747568fe42ee5c.tar.bz2 rails-769f73cc18c58021d49a3b93f1747568fe42ee5c.zip |
Dispatch actions only if config.consider_all_requests_local is set
-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: { |