diff options
author | Jorge Bejar <jorge@wyeworks.com> | 2015-07-06 14:12:00 -0300 |
---|---|---|
committer | Jorge Bejar <jorge@wyeworks.com> | 2015-12-08 21:23:47 -0300 |
commit | b79bfaadaf5b5c6d3e458c24184a0e846bd8cf55 (patch) | |
tree | 4ad6e30dec0ffd6380bf85226e8555e2acab5fd3 /actionpack/test/dispatch | |
parent | a61e4ae58d65d43a97e90bdb02b6c407791e3c53 (diff) | |
download | rails-b79bfaadaf5b5c6d3e458c24184a0e846bd8cf55.tar.gz rails-b79bfaadaf5b5c6d3e458c24184a0e846bd8cf55.tar.bz2 rails-b79bfaadaf5b5c6d3e458c24184a0e846bd8cf55.zip |
Use URL path extension as format in bad params exception handling
Diffstat (limited to 'actionpack/test/dispatch')
-rw-r--r-- | actionpack/test/dispatch/show_exceptions_test.rb | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/actionpack/test/dispatch/show_exceptions_test.rb b/actionpack/test/dispatch/show_exceptions_test.rb index ffdf775836..14894d4b82 100644 --- a/actionpack/test/dispatch/show_exceptions_test.rb +++ b/actionpack/test/dispatch/show_exceptions_test.rb @@ -8,7 +8,7 @@ class ShowExceptionsTest < ActionDispatch::IntegrationTest case req.path when "/not_found" raise AbstractController::ActionNotFound - when "/bad_params" + when "/bad_params", "/bad_params.json" begin raise StandardError.new rescue @@ -120,4 +120,18 @@ class ShowExceptionsTest < ActionDispatch::IntegrationTest assert_response 405 assert_equal "", body end + + test "bad params exception is returned in the correct format" do + @app = ProductionApp + + get "/bad_params", headers: { 'action_dispatch.show_exceptions' => true } + assert_equal "text/html; charset=utf-8", response.headers["Content-Type"] + assert_response 400 + assert_match(/400 error/, body) + + get "/bad_params.json", headers: { 'action_dispatch.show_exceptions' => true } + assert_equal "application/json; charset=utf-8", response.headers["Content-Type"] + assert_response 400 + assert_equal("{\"status\":400,\"error\":\"Bad Request\"}", body) + end end |