aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch
diff options
context:
space:
mode:
authorKir Shatrov <shatrov@me.com>2013-08-21 16:42:04 +0400
committerKir Shatrov <shatrov@me.com>2013-08-22 22:20:34 +0400
commita725a453b38057b46878afae39dc107ada2cf326 (patch)
tree7fca3f5d7bf97e4110c4b05a533f371b10af047c /actionpack/test/dispatch
parent998d9c89e42d41f99b1970ce229cc4b818db3680 (diff)
downloadrails-a725a453b38057b46878afae39dc107ada2cf326.tar.gz
rails-a725a453b38057b46878afae39dc107ada2cf326.tar.bz2
rails-a725a453b38057b46878afae39dc107ada2cf326.zip
Display exceptions in text format for xhr request
Diffstat (limited to 'actionpack/test/dispatch')
-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