mirror of https://github.com/rails/rails
Merge pull request #48956 from skipkayhil/hm-rack-lint-show-exceptions-failsafe
Add test coverage for ShowExceptions failsafe
This commit is contained in:
commit
5a21634407
|
@ -54,7 +54,7 @@ module ActionDispatch
|
|||
rescue Exception => failsafe_error
|
||||
$stderr.puts "Error during failsafe response: #{failsafe_error}\n #{failsafe_error.backtrace * "\n "}"
|
||||
|
||||
[500, { "Content-Type" => "text/plain; charset=utf-8" },
|
||||
[500, { Rack::CONTENT_TYPE => "text/plain; charset=utf-8" },
|
||||
["500 Internal Server Error\n" \
|
||||
"If you are the administrator of this website, then please read this web " \
|
||||
"application's log file and/or the web server's log file to find out what " \
|
||||
|
|
|
@ -135,6 +135,18 @@ class ShowExceptionsTest < ActionDispatch::IntegrationTest
|
|||
assert_equal("{\"status\":400,\"error\":\"Bad Request\"}", body)
|
||||
end
|
||||
|
||||
test "failsafe prevents raising if exceptions_app raises" do
|
||||
old_stderr, $stderr = $stderr, StringIO.new
|
||||
@app = build_app(->(_) { raise })
|
||||
|
||||
get "/"
|
||||
|
||||
assert_response 500
|
||||
assert_match(/500 Internal Server Error/, body)
|
||||
ensure
|
||||
$stderr = old_stderr
|
||||
end
|
||||
|
||||
private
|
||||
def build_app(exceptions_app = nil)
|
||||
exceptions_app ||= ActionDispatch::PublicExceptions.new("#{FIXTURE_LOAD_PATH}/public")
|
||||
|
|
Loading…
Reference in New Issue