-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FFS-1427: Implement custom 404/500 errors
- Loading branch information
Showing
13 changed files
with
117 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,23 @@ | ||
class PagesController < ApplicationController | ||
def home | ||
end | ||
|
||
def error_404 | ||
# When in development environment, you'll need to set | ||
# config.consider_all_requests_local = false | ||
# in config/development.rb for these pages to actually show up. | ||
@cbv_flow = if session[:cbv_flow_id] | ||
CbvFlow.find(session[:cbv_flow_id]) | ||
end | ||
|
||
render status: :not_found, formats: %i[html] | ||
end | ||
|
||
def error_500 | ||
# When in development environment, you'll need to set | ||
# config.consider_all_requests_local = false | ||
# in config/development.rb for these pages to actually show up. | ||
|
||
render status: :internal_server_error, formats: %i[html] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<% header = t(".header") %> | ||
<% content_for :title, header %> | ||
<h1><%= header %></h1> | ||
|
||
<div class="usa-prose"> | ||
<p><%= t(".error_code_html") %></p> | ||
|
||
<% if @cbv_flow && @cbv_flow.cbv_flow_invitation %> | ||
<%= link_to t(".return_to_entry"), @cbv_flow.cbv_flow_invitation.to_url %> | ||
<% else %> | ||
<%= link_to t(".return_to_welcome"), root_url %> | ||
<% end %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<% header = t(".header") %> | ||
<% content_for :title, header %> | ||
<h1><%= header %></h1> | ||
|
||
<div class="usa-prose"> | ||
<p><%= t(".error_code_html") %></p> | ||
|
||
<p><%= t(".description") %></p> | ||
|
||
<p> | ||
<%= link_to t(".refresh"), "javascript:window.location.reload()" %> | ||
</p> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe PagesController do | ||
render_views | ||
|
||
describe "#home" do | ||
it "renders" do | ||
get :home | ||
expect(response).to be_successful | ||
expect(response.body).to include("Welcome") | ||
end | ||
end | ||
|
||
describe "#error_404" do | ||
it "renders with a link to the homepage" do | ||
get :error_404 | ||
expect(response.status).to eq(404) | ||
expect(response.body).to include("We can't find the page") | ||
expect(response.body).to include("Return to welcome") | ||
end | ||
|
||
describe "when a cbv_flow_id is in the session" do | ||
let(:cbv_flow) { create(:cbv_flow) } | ||
|
||
it "renders with a link to restart that CBV flow" do | ||
get :error_404, session: { cbv_flow_id: cbv_flow.id } | ||
expect(response.status).to eq(404) | ||
expect(response.body).to include("Return to entry page") | ||
end | ||
end | ||
end | ||
|
||
describe "#error_500" do | ||
it "renders" do | ||
get :error_500 | ||
expect(response.status).to eq(500) | ||
expect(response.body).to include("It looks like something went wrong") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,16 @@ | ||
network.globalExclusions.exclusions(0).exclusion.name=Search | ||
network.globalExclusions.exclusions(0).exclusion.enabled=true | ||
network.globalExclusions.exclusions(0).exclusion.value=/.*\/(?:.{2}\/)?cbv\/employer_search\?authenticity\_token.*/gm | ||
|
||
# Ignore CSP warnings on sitemap.xml | ||
globalalertfilter.filters.filter(0).ruleid=10038 | ||
globalalertfilter.filters.filter(0).newrisk=-1 | ||
globalalertfilter.filters.filter(0).url=.*/sitemap.xml$ | ||
globalalertfilter.filters.filter(0).urlregex=true | ||
globalalertfilter.filters.filter(0).param= | ||
globalalertfilter.filters.filter(0).paramregex=false | ||
globalalertfilter.filters.filter(0).attack= | ||
globalalertfilter.filters.filter(0).attackregex=false | ||
globalalertfilter.filters.filter(0).evidence= | ||
globalalertfilter.filters.filter(0).evidenceregex=false | ||
globalalertfilter.filters.filter(0).enabled=true |