Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #739 from trade-tariff/HOTT-4630-error-controller
HOTT-4630: Extend DutyCalculator ErrorsController
- Loading branch information
Showing
14 changed files
with
189 additions
and
119 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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<main role="main" class="govuk-main-wrapper" id="main-content"> | ||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-full-width"> | ||
<h1 class="govuk-heading-xl"><%= header %></h1> | ||
<p class="govuk-body"><%= message %></p> | ||
|
||
<% if user_session.commodity_code.present? %> | ||
<p class="govuk-body">Click here to <%= link_to('start again', import_date_path(referred_service: user_session.referred_service, commodity_code: user_session.commodity_code), class: 'govuk-link') %>.</p> | ||
<% end %> | ||
</div> | ||
</div> | ||
</main> |
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
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 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,92 @@ | ||
RSpec.describe ErrorsController, type: :request do | ||
include ApplicationHelper | ||
|
||
subject(:rendered) { make_request && response } | ||
|
||
let(:json_response) { JSON.parse(rendered.body) } | ||
let(:body) { rendered.body } | ||
|
||
shared_examples 'a json error response' do |status_code, message| | ||
it { is_expected.to have_http_status status_code } | ||
it { is_expected.to have_attributes media_type: 'application/json' } | ||
it { expect(json_response).to include 'error' => message } | ||
end | ||
|
||
describe 'GET /400.json' do | ||
let(:make_request) { get '/400.json' } | ||
|
||
it_behaves_like 'a json error response', 400, 'Bad request' | ||
end | ||
|
||
describe 'GET /404.json' do | ||
let(:make_request) { get '/404.json' } | ||
|
||
it_behaves_like 'a json error response', 404, 'Resource not found' | ||
end | ||
|
||
describe 'GET /405.json' do | ||
let(:make_request) { get '/405.json' } | ||
|
||
it_behaves_like 'a json error response', 405, 'Method not allowed' | ||
end | ||
|
||
describe 'GET /406.json' do | ||
let(:make_request) { get '/406.json' } | ||
|
||
it_behaves_like 'a json error response', 406, 'Not acceptable' | ||
end | ||
|
||
describe 'GET /422.json' do | ||
let(:make_request) { get '/422.json' } | ||
|
||
it_behaves_like 'a json error response', 422, 'Unprocessable entity' | ||
end | ||
|
||
describe 'GET /500.json' do | ||
let(:make_request) { get '/500.json' } | ||
|
||
it_behaves_like 'a json error response', 500, 'Internal server error' | ||
end | ||
|
||
describe 'GET /501.json' do | ||
let(:make_request) { get '/501.json' } | ||
|
||
it_behaves_like 'a json error response', 501, 'Not implemented' | ||
end | ||
|
||
describe 'GET /400' do | ||
let(:make_request) { get '/400' } | ||
|
||
it { expect(body).to include 'Bad request' } | ||
end | ||
|
||
describe 'GET /404' do | ||
let(:make_request) { get '/404' } | ||
|
||
it { expect(body).to include 'The page you were looking for does not exist.' } | ||
end | ||
|
||
describe 'GET /406' do | ||
let(:make_request) { get '/406' } | ||
|
||
it { expect(body).to include 'Not acceptable' } | ||
end | ||
|
||
describe 'GET /422' do | ||
let(:make_request) { get '/422' } | ||
|
||
it { expect(body).to include 'The change you wanted was rejected.' } | ||
end | ||
|
||
describe 'GET /500' do | ||
let(:make_request) { get '/500' } | ||
|
||
it { expect(body).to include 'Sorry, there is a problem with the service' } | ||
end | ||
|
||
describe 'GET #501' do | ||
let(:make_request) { get '/501' } | ||
|
||
it { expect(body).to include 'Not implemented' } | ||
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 @@ | ||
RSpec.describe 'errors/error', type: :view do | ||
let(:user_session) { build(:user_session, :with_commodity_information) } | ||
|
||
it 'renders a link to the import_date_path' do | ||
render template: 'errors/error', | ||
locals: { user_session:, header: 'Error header', message: 'Error message' } | ||
|
||
expected_path = import_date_path(referred_service: user_session.referred_service, | ||
commodity_code: user_session.commodity_code) | ||
|
||
expect(rendered).to include(expected_path) | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.