mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #42244 from hahmed/fix-invalid-statement-compile-error
Fix invalid statement template compile error
This commit is contained in:
commit
b0d8d82760
2 changed files with 24 additions and 0 deletions
|
@ -6,6 +6,7 @@
|
|||
<%= @exception.message %>
|
||||
<% if defined?(ActiveStorage) && @exception.message.match?(%r{#{ActiveStorage::Blob.table_name}|#{ActiveStorage::Attachment.table_name}}) %>
|
||||
To resolve this issue run: bin/rails active_storage:install
|
||||
<% end %>
|
||||
<% if defined?(ActionMailbox) && @exception.message.match?(%r{#{ActionMailbox::InboundEmail.table_name}}) %>
|
||||
To resolve this issue run: bin/rails action_mailbox:install
|
||||
<% end %>
|
||||
|
|
|
@ -171,5 +171,28 @@ module ApplicationTests
|
|||
assert_equal 400, last_response.status
|
||||
assert_match "Invalid query parameters", last_response.body
|
||||
end
|
||||
|
||||
test "displays statement invalid template correctly" do
|
||||
controller :foo, <<-RUBY
|
||||
class FooController < ActionController::Base
|
||||
def index
|
||||
raise ActiveRecord::StatementInvalid
|
||||
end
|
||||
end
|
||||
RUBY
|
||||
app.config.action_dispatch.show_exceptions = true
|
||||
app.config.consider_all_requests_local = true
|
||||
app.config.action_dispatch.ignore_accept_header = false
|
||||
|
||||
get "/foo"
|
||||
assert_equal 500, last_response.status
|
||||
assert_match "<title>Action Controller: Exception caught</title>", last_response.body
|
||||
assert_match "ActiveRecord::StatementInvalid", last_response.body
|
||||
|
||||
get "/foo", {}, { "HTTP_ACCEPT" => "text/plain", "HTTP_X_REQUESTED_WITH" => "XMLHttpRequest" }
|
||||
assert_equal 500, last_response.status
|
||||
assert_equal "text/plain", last_response.media_type
|
||||
assert_match "ActiveRecord::StatementInvalid", last_response.body
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue