aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2013-08-23 13:52:15 -0700
committerRafael Mendonça França <rafaelmfranca@gmail.com>2013-08-23 13:52:15 -0700
commit043c8707bf0a87beb3906643ddfd1b60f52c1a98 (patch)
tree46a95234f2ad9e57b80096793412bae60d20f0e9 /actionpack/test
parentb77f25cb8479a8ff6c93b1d6bbf0771e5368434f (diff)
parenta725a453b38057b46878afae39dc107ada2cf326 (diff)
downloadrails-043c8707bf0a87beb3906643ddfd1b60f52c1a98.tar.gz
rails-043c8707bf0a87beb3906643ddfd1b60f52c1a98.tar.bz2
rails-043c8707bf0a87beb3906643ddfd1b60f52c1a98.zip
Merge pull request #11960 from kirs/xhr-errors
Show exceptions in text format for xhr requests
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/dispatch/debug_exceptions_test.rb41
1 files changed, 41 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/debug_exceptions_test.rb b/actionpack/test/dispatch/debug_exceptions_test.rb
index ff0baccd76..3045a07ad6 100644
--- a/actionpack/test/dispatch/debug_exceptions_test.rb
+++ b/actionpack/test/dispatch/debug_exceptions_test.rb
@@ -128,6 +128,47 @@ class DebugExceptionsTest < ActionDispatch::IntegrationTest
assert_match(/ActionController::ParameterMissing/, body)
end
+ test "rescue with text error for xhr request" do
+ @app = DevelopmentApp
+ xhr_request_env = {'action_dispatch.show_exceptions' => true, 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest'}
+
+ get "/", {}, xhr_request_env
+ assert_response 500
+ assert_no_match(/<body>/, body)
+ assert_equal response.content_type, "text/plain"
+ assert_match(/puke/, body)
+
+ get "/not_found", {}, xhr_request_env
+ assert_response 404
+ assert_no_match(/<body>/, body)
+ assert_equal response.content_type, "text/plain"
+ assert_match(/#{AbstractController::ActionNotFound.name}/, body)
+
+ get "/method_not_allowed", {}, xhr_request_env
+ assert_response 405
+ assert_no_match(/<body>/, body)
+ assert_equal response.content_type, "text/plain"
+ assert_match(/ActionController::MethodNotAllowed/, body)
+
+ get "/unknown_http_method", {}, xhr_request_env
+ assert_response 405
+ assert_no_match(/<body>/, body)
+ assert_equal response.content_type, "text/plain"
+ assert_match(/ActionController::UnknownHttpMethod/, body)
+
+ get "/bad_request", {}, xhr_request_env
+ assert_response 400
+ assert_no_match(/<body>/, body)
+ assert_equal response.content_type, "text/plain"
+ assert_match(/ActionController::BadRequest/, body)
+
+ get "/parameter_missing", {}, xhr_request_env
+ assert_response 400
+ assert_no_match(/<body>/, body)
+ assert_equal response.content_type, "text/plain"
+ assert_match(/ActionController::ParameterMissing/, body)
+ end
+
test "does not show filtered parameters" do
@app = DevelopmentApp