Skip to content

Commit

Permalink
Merge pull request #42244 from hahmed/fix-invalid-statement-compile-e…
Browse files Browse the repository at this point in the history
…rror

Fix invalid statement template compile error
  • Loading branch information
rafaelfranca committed Jun 10, 2021
1 parent 96a3611 commit 3bbf3ac
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Expand Up @@ -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 %>
Expand Down
23 changes: 23 additions & 0 deletions railties/test/application/middleware/exceptions_test.rb
Expand Up @@ -171,5 +171,28 @@ def index
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

0 comments on commit 3bbf3ac

Please sign in to comment.