diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-04-30 17:38:56 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-04-30 17:38:56 -0700 |
commit | fd890f6aea4a0699aab33f70892c33e5212ab728 (patch) | |
tree | 0ac65759cb191b0d6dcb5bd25f7505780efab5ed /actionpack | |
parent | c68b6f0638fc1b5f8b6b1b5202de476a0ac431ea (diff) | |
parent | ea2336b9e2c47a9cc1a73b1350ffc03252e6468e (diff) | |
download | rails-fd890f6aea4a0699aab33f70892c33e5212ab728.tar.gz rails-fd890f6aea4a0699aab33f70892c33e5212ab728.tar.bz2 rails-fd890f6aea4a0699aab33f70892c33e5212ab728.zip |
Merge pull request #9857 from yyyc514/bad_params_should_400
failure to parse params should trigger a 400 Bad Request
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/exception_wrapper.rb | 1 | ||||
-rw-r--r-- | actionpack/test/dispatch/show_exceptions_test.rb | 6 | ||||
-rw-r--r-- | actionpack/test/fixtures/public/400.html | 1 |
3 files changed, 8 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/exception_wrapper.rb b/actionpack/lib/action_dispatch/middleware/exception_wrapper.rb index 0a19381c89..1de3d14530 100644 --- a/actionpack/lib/action_dispatch/middleware/exception_wrapper.rb +++ b/actionpack/lib/action_dispatch/middleware/exception_wrapper.rb @@ -13,6 +13,7 @@ module ActionDispatch 'ActionController::NotImplemented' => :not_implemented, 'ActionController::UnknownFormat' => :not_acceptable, 'ActionController::InvalidAuthenticityToken' => :unprocessable_entity, + 'ActionDispatch::ParamsParser::ParseError' => :bad_request, 'ActionController::BadRequest' => :bad_request, 'ActionController::ParameterMissing' => :bad_request ) diff --git a/actionpack/test/dispatch/show_exceptions_test.rb b/actionpack/test/dispatch/show_exceptions_test.rb index 98bbcd954b..38bd234f37 100644 --- a/actionpack/test/dispatch/show_exceptions_test.rb +++ b/actionpack/test/dispatch/show_exceptions_test.rb @@ -8,6 +8,8 @@ class ShowExceptionsTest < ActionDispatch::IntegrationTest case req.path when "/not_found" raise AbstractController::ActionNotFound + when "/bad_params" + raise ActionDispatch::ParamsParser::ParseError.new("", StandardError.new) when "/method_not_allowed" raise ActionController::MethodNotAllowed when "/unknown_http_method" @@ -35,6 +37,10 @@ class ShowExceptionsTest < ActionDispatch::IntegrationTest get "/", {}, {'action_dispatch.show_exceptions' => true} assert_response 500 assert_equal "500 error fixture\n", body + + get "/bad_params", {}, {'action_dispatch.show_exceptions' => true} + assert_response 400 + assert_equal "400 error fixture\n", body get "/not_found", {}, {'action_dispatch.show_exceptions' => true} assert_response 404 diff --git a/actionpack/test/fixtures/public/400.html b/actionpack/test/fixtures/public/400.html new file mode 100644 index 0000000000..03be6bedaf --- /dev/null +++ b/actionpack/test/fixtures/public/400.html @@ -0,0 +1 @@ +400 error fixture |