Merge pull request #42244 from hahmed/fix-invalid-statement-compile-error

Fix invalid statement template compile error
This commit is contained in:
Rafael França 2021-06-09 22:24:30 -04:00 committed by GitHub
commit b0d8d82760
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View File

@ -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 %>

View File

@ -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