chore: custom dynamic & static 500 pages
This commit is contained in:
parent
7dcd4ba538
commit
5d23b37f59
9 changed files with 2274 additions and 51 deletions
18
spec/support/without_detailed_exceptions.rb
Normal file
18
spec/support/without_detailed_exceptions.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
module WithoutDetailedExceptions
|
||||
RSpec.configure do |config|
|
||||
config.include self, type: :system
|
||||
end
|
||||
|
||||
# Snippet from https://github.com/rspec/rspec-rails/issues/2024
|
||||
def without_detailed_exceptions
|
||||
env_config = Rails.application.env_config
|
||||
original_show_exceptions = env_config['action_dispatch.show_exceptions']
|
||||
original_show_detailed_exceptions = env_config['action_dispatch.show_detailed_exceptions']
|
||||
env_config['action_dispatch.show_exceptions'] = true
|
||||
env_config['action_dispatch.show_detailed_exceptions'] = false
|
||||
yield
|
||||
ensure
|
||||
env_config['action_dispatch.show_exceptions'] = original_show_exceptions
|
||||
env_config['action_dispatch.show_detailed_exceptions'] = original_show_detailed_exceptions
|
||||
end
|
||||
end
|
29
spec/system/errors_spec.rb
Normal file
29
spec/system/errors_spec.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
describe 'Errors handling', js: false do
|
||||
let(:procedure) { create(:procedure) }
|
||||
|
||||
scenario 'bug renders dynamic 500 page' do
|
||||
procedure.revisions.destroy_all # break procedure
|
||||
|
||||
without_detailed_exceptions do
|
||||
visit commencer_path(path: procedure.path)
|
||||
end
|
||||
|
||||
expect(page).to have_http_status(:internal_server_error)
|
||||
expect(page).to have_content('une erreur est survenue')
|
||||
expect(page).to have_content('Se connecter')
|
||||
expect(page).to have_link('Contactez-nous')
|
||||
end
|
||||
|
||||
scenario 'fatal error fallback to static 500 page' do
|
||||
without_detailed_exceptions do
|
||||
Rails.application.env_config["action_dispatch.cookies"] = "will fail"
|
||||
visit commencer_path(path: procedure.path)
|
||||
ensure
|
||||
Rails.application.env_config.delete("action_dispatch.cookies")
|
||||
end
|
||||
|
||||
expect(page).to have_content('une erreur est survenue')
|
||||
expect(page).not_to have_content('Se connecter')
|
||||
expect(page).to have_link('Contactez-nous')
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue