mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Show source view and backtrace on missing template errors
This will help you debug missing template errors, especially if they come from a programmatic template selection. Thanks to @dhh for suggesting that. As a bonus, also show request and response info on the routing error page for consistency.
This commit is contained in:
parent
77fbc53586
commit
92ace39692
3 changed files with 33 additions and 0 deletions
|
@ -4,4 +4,8 @@
|
||||||
|
|
||||||
<div id="container">
|
<div id="container">
|
||||||
<h2><%= h @exception.message %></h2>
|
<h2><%= h @exception.message %></h2>
|
||||||
|
|
||||||
|
<%= render template: "rescues/_source" %>
|
||||||
|
<%= render template: "rescues/_trace" %>
|
||||||
|
<%= render template: "rescues/_request_and_response" %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -27,4 +27,6 @@
|
||||||
|
|
||||||
<%= @routes_inspector.format(ActionDispatch::Routing::HtmlTableFormatter.new(self)) %>
|
<%= @routes_inspector.format(ActionDispatch::Routing::HtmlTableFormatter.new(self)) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<%= render template: "rescues/_request_and_response" %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -43,6 +43,8 @@ class DebugExceptionsTest < ActionDispatch::IntegrationTest
|
||||||
raise ActionController::InvalidAuthenticityToken
|
raise ActionController::InvalidAuthenticityToken
|
||||||
when "/not_found_original_exception"
|
when "/not_found_original_exception"
|
||||||
raise ActionView::Template::Error.new('template', AbstractController::ActionNotFound.new)
|
raise ActionView::Template::Error.new('template', AbstractController::ActionNotFound.new)
|
||||||
|
when "/missing_template"
|
||||||
|
raise ActionView::MissingTemplate.new(%w(foo), 'foo/index', %w(foo), false, 'mailer')
|
||||||
when "/bad_request"
|
when "/bad_request"
|
||||||
raise ActionController::BadRequest
|
raise ActionController::BadRequest
|
||||||
when "/missing_keys"
|
when "/missing_keys"
|
||||||
|
@ -120,6 +122,15 @@ class DebugExceptionsTest < ActionDispatch::IntegrationTest
|
||||||
assert_no_match '<|>', routing_table, "there should not be escaped html in the output"
|
assert_no_match '<|>', routing_table, "there should not be escaped html in the output"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test 'displays request and response info when a RoutingError occurs' do
|
||||||
|
@app = DevelopmentApp
|
||||||
|
|
||||||
|
get "/pass", {}, {'action_dispatch.show_exceptions' => true}
|
||||||
|
|
||||||
|
assert_select 'h2', /Request/
|
||||||
|
assert_select 'h2', /Response/
|
||||||
|
end
|
||||||
|
|
||||||
test "rescue with diagnostics message" do
|
test "rescue with diagnostics message" do
|
||||||
@app = DevelopmentApp
|
@app = DevelopmentApp
|
||||||
|
|
||||||
|
@ -275,6 +286,22 @@ class DebugExceptionsTest < ActionDispatch::IntegrationTest
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test 'display backtrace on template missing errors' do
|
||||||
|
@app = DevelopmentApp
|
||||||
|
|
||||||
|
get "/missing_template", nil, {}
|
||||||
|
|
||||||
|
assert_select "header h1", /Template is missing/
|
||||||
|
|
||||||
|
assert_select "#container h2", /^Missing template/
|
||||||
|
|
||||||
|
assert_select '#Application-Trace'
|
||||||
|
assert_select '#Framework-Trace'
|
||||||
|
assert_select '#Full-Trace'
|
||||||
|
|
||||||
|
assert_select 'h2', /Request/
|
||||||
|
end
|
||||||
|
|
||||||
test 'display backtrace when error type is SyntaxError wrapped by ActionView::Template::Error' do
|
test 'display backtrace when error type is SyntaxError wrapped by ActionView::Template::Error' do
|
||||||
@app = DevelopmentApp
|
@app = DevelopmentApp
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue