Permalink
Browse files

Merge pull request #9857 from yyyc514/bad_params_should_400

failure to parse params should trigger a 400 Bad Request
  • Loading branch information...
2 parents c68b6f0 + ea2336b commit fd890f6aea4a0699aab33f70892c33e5212ab728 @tenderlove tenderlove committed May 1, 2013
@@ -13,6 +13,7 @@ class ExceptionWrapper
'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
)
@@ -8,6 +8,8 @@ def call(env)
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 @@ def call(env)
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
@@ -0,0 +1 @@
+400 error fixture

0 comments on commit fd890f6

Please sign in to comment.