Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Content Publisher returning 500 on document 404s
Content Publisher currently returns an unstyled 500 error [1] when a 404 page is encountered. This happens because an exception loop occurs during the rendering of an error response. The problem occurs because `check_user_access` before action runs before all actions (including error actions). So if a document is going to 404, the `ActiveRecord::RecordNotFound` is raised once before the requested action and then again in the ErrorsController. To avoid this we are using skip_before_action callback in ErrorsController so the `check_user_access` action only runs once. We are setting `config.action_dispatch.show_exceptions` to true in the test environment so exceptions are rescued and Rails returns a corresponding HTTP status code instead of returning `ActiveRecord::RecordNotFound` exeption [1] https://github.com/rails/rails/blob/98a57aa5f610bc66af31af409c72173cdeeb3c9e/actionpack/lib/action_dispatch/middleware/show_exceptions.rb#L20-L24
- Loading branch information