Skip to content

Commit

Permalink
Merge pull request #2167 from alphagov/add-missing-error-pages
Browse files Browse the repository at this point in the history
Add missing pages for known errors
  • Loading branch information
benthorner authored May 14, 2020
2 parents d1e9d78 + 405b02d commit bae456f
Show file tree
Hide file tree
Showing 17 changed files with 60 additions and 30 deletions.
1 change: 1 addition & 0 deletions app/assets/stylesheets/error-page-print.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ $is-print: true;
@import "govuk_publishing_components/component_support";
@import "govuk_publishing_components/components/print/button";
@import "govuk_publishing_components/components/print/feedback";
@import "govuk_publishing_components/components/_warning-text";
1 change: 1 addition & 0 deletions app/assets/stylesheets/error-page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ $govuk-use-legacy-palette: false;
@import "govuk_publishing_components/components/_cookie-banner";
@import "govuk_publishing_components/components/_button";
@import "govuk_publishing_components/components/_feedback";
@import "govuk_publishing_components/components/_warning-text";
2 changes: 1 addition & 1 deletion app/views/root/400.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%= render partial: "error_page", locals: {
title: "Bad request - 400",
title: "Bad request",
heading: "Bad request",
intro: '',
status_code: 400
Expand Down
6 changes: 6 additions & 0 deletions app/views/root/401.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<%= render partial: "error_page", locals: {
title: "Unauthorized",
heading: "You are not permitted to access this page",
intro: '<p>This page is restricted to certain users only.</p>',
status_code: 401
} %>
2 changes: 1 addition & 1 deletion app/views/root/403.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%= render partial: "error_page", locals: {
title: "Forbidden - 403",
title: "Forbidden",
heading: "You are not permitted to see this page",
intro: '<p>This page is restricted to certain users only.</p>',
status_code: 403
Expand Down
2 changes: 1 addition & 1 deletion app/views/root/404.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%= render partial: "error_page", locals: {
title: "Page not found - 404",
title: "Page not found",
heading: "Page not found",
intro: '<p>If you entered a web address please check it was correct.</p>

Expand Down
7 changes: 7 additions & 0 deletions app/views/root/405.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<%= render partial: "error_page", locals: {
title: "Method not allowed",
heading: "You are not permitted to perform this action",
intro: '<p>This page does not support the action you requested.</p>',
status_code: 405
} %>

2 changes: 1 addition & 1 deletion app/views/root/406.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%= render partial: "error_page", locals: {
title: "Page not found - 406",
title: "Page not found",
heading: "The page you are looking for can't be found",
intro: '<p>Please check that you have entered the correct web address, or try using the search box above or explore <a class="govuk-link" href="/">GOV.UK</a> to find the information you need.</p>',
status_code: 406
Expand Down
2 changes: 1 addition & 1 deletion app/views/root/410.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%= render partial: "error_page", locals: {
title: "Page no longer here - 410",
title: "Page no longer here",
heading: "The page you are looking for is no longer here",
intro: '<p>It may have been moved or replaced.</p>
<p>Please check that you have entered the correct web address, or try using the search box above or explore <a class="govuk-link" href="/">GOV.UK</a> to find the information you need.</p>',
Expand Down
7 changes: 7 additions & 0 deletions app/views/root/429.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<%= render partial: "error_page", locals: {
title: "Sorry, there was a problem",
heading: "Sorry, there was a problem",
intro: '<p>You have made too many requests to this page.</p>
<p>Try again later.</p>',
status_code: 429
} %>
7 changes: 6 additions & 1 deletion app/views/root/500.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
<%= render partial: "error_page", locals: {status_code: 500} %>
<%= render partial: "error_page", locals: {
title: "Sorry, we're experiencing technical difficulties",
heading: "Sorry, we're experiencing technical difficulties",
intro: "<p>Please try again in a few moments.</p>",
status_code: 500
} %>
7 changes: 6 additions & 1 deletion app/views/root/501.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
<%= render partial: "error_page", locals: {status_code: 501} %>
<%= render partial: "error_page", locals: {
title: "Sorry, we're experiencing technical difficulties",
heading: "Sorry, we're experiencing technical difficulties",
intro: "<p>Please try again in a few moments.</p>",
status_code: 501
} %>
7 changes: 6 additions & 1 deletion app/views/root/503.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
<%= render partial: "error_page", locals: {status_code: 503} %>
<%= render partial: "error_page", locals: {
title: "Sorry, we're experiencing technical difficulties",
heading: "Sorry, we're experiencing technical difficulties",
intro: "<p>Please try again in a few moments.</p>",
status_code: 503
} %>
7 changes: 6 additions & 1 deletion app/views/root/504.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
<%= render partial: "error_page", locals: {status_code: 504} %>
<%= render partial: "error_page", locals: {
title: "Sorry, we're experiencing technical difficulties",
heading: "Sorry, we're experiencing technical difficulties",
intro: "<p>Please try again in a few moments.</p>",
status_code: 504
} %>
20 changes: 5 additions & 15 deletions app/views/root/_error_page.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,29 @@

<% content_for :wrapper_content do %>
<main id="content" role="main" class="group">

<header class="page-header group">
<div>
<% if local_assigns.include?(:heading) %>
<h1><%= heading %></h1>
<% else %>
<h1>Sorry, we're experiencing technical difficulties</h1>
<% end %>
<h1><%= heading %></h1>
</div>
</header>
<div class="article-container">
<article role="article" class="group">
<div class="inner">
<% if local_assigns.include?(:intro) %>
<%= raw intro %>
<% else %>
<p>Please try again in a few moments.</p>
<% end %>
<%= render "govuk_publishing_components/components/warning_text", {
text: "Status code: #{status_code}"
} %>

<%= raw intro %>
<p>You can <a class="govuk-link" href="/coronavirus">find coronavirus information</a> on GOV.UK.</p>
</div>
</article>
</div>

<% if status_code.in?(400..499) %>
<%= render "govuk_publishing_components/components/feedback" %>
<% end %>

<% if status_code %>
<script type="text/javascript">
window.httpStatusCode = '<%= status_code %>';
</script>
<% end %>
</main>
<% end %>

Expand Down
5 changes: 2 additions & 3 deletions test/integration/templates/error_4xx_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ class Error4XXTest < ActionDispatch::IntegrationTest

assert page.has_selector?("body.mainstream.error")
within "head", visible: :all do
assert page.has_selector?("title", text: "Page not found - 404 - GOV.UK", visible: :all)

assert page.has_selector?("title", text: "Page not found - GOV.UK", visible: :all)
assert page.has_selector?("link[href='/static/static.css']", visible: :all)
end

Expand All @@ -21,11 +20,11 @@ class Error4XXTest < ActionDispatch::IntegrationTest

within "#wrapper" do
assert page.has_selector?("h1", text: "Page not found")
assert page.has_selector?(".govuk-warning-text__text", text: "Status code: 404", visible: :all)
end

within "footer" do
assert page.has_selector?(".footer-categories")

assert page.has_selector?(".footer-meta")
end
end
Expand Down
5 changes: 2 additions & 3 deletions test/integration/templates/error_5xx_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ class Error5XXTest < ActionDispatch::IntegrationTest

assert page.has_selector?("body.mainstream.error")
within "head", visible: :all do
assert page.has_selector?("title", text: "Sorry, we're experiencing technical difficulties (500 error) - GOV.UK", visible: :all)

assert page.has_selector?("title", text: "Sorry, we're experiencing technical difficulties - GOV.UK", visible: :all)
assert page.has_selector?("link[href='/static/static.css']", visible: :all)
end

Expand All @@ -21,11 +20,11 @@ class Error5XXTest < ActionDispatch::IntegrationTest

within "#wrapper" do
assert page.has_selector?("h1", text: "Sorry, we're experiencing technical difficulties")
assert page.has_selector?(".govuk-warning-text__text", text: "Status code: 500", visible: :all)
end

within "footer" do
assert page.has_selector?(".footer-categories")

assert page.has_selector?(".footer-meta")
end
end
Expand Down

0 comments on commit bae456f

Please sign in to comment.