-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add change links - make conditional back links - populated fields - reset corrected name
- Loading branch information
1 parent
481ae2c
commit 3b87ab3
Showing
12 changed files
with
159 additions
and
22 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
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
10 changes: 8 additions & 2 deletions
10
app/views/schools/register_mentor_wizard/email_address.html.erb
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,12 +1,18 @@ | ||
<% page_data(title: "What is #{@mentor.full_name}'s email address?", error: @wizard.current_step.errors.present?, backlink_href: schools_register_mentor_wizard_review_mentor_details_path) %> | ||
<% | ||
page_data( | ||
title: "What is #{@mentor.full_name}'s email address?", | ||
error: @wizard.current_step.errors.present?, | ||
backlink_href: @mentor.email.present? ? schools_register_mentor_wizard_check_answers_path : schools_register_mentor_wizard_review_mentor_details_path | ||
) | ||
%> | ||
|
||
<p class="govuk-body">We need an email so we can ask for their consent to share their details if needed for | ||
training.</p> | ||
|
||
<%= form_with(model: @wizard.current_step, url: @wizard.current_step_path) do |f| %> | ||
<%= content_for(:error_summary) { f.govuk_error_summary } %> | ||
|
||
<%= f.govuk_email_field(:email, label: { text: "Email address", hidden: true, class: 'govuk-!-margin-bottom-4' }) %> | ||
<%= f.govuk_email_field(:email, value: @mentor.email, label: { text: "Email address", hidden: true, class: 'govuk-!-margin-bottom-4' }) %> | ||
|
||
<%= f.govuk_submit "Continue" %> | ||
<% 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,12 +4,14 @@ | |
let(:ect_name) { "Michael Dixon" } | ||
let(:title) { "Check your answers and confirm mentor details" } | ||
let(:store) do | ||
double(trn: "1234567", | ||
trs_first_name: "John", | ||
trs_last_name: "Wayne", | ||
corrected_name: "Jim Wayne", | ||
email: "[email protected]") | ||
FactoryBot.build(:session_repository, | ||
trn: "1234567", | ||
trs_first_name: "John", | ||
trs_last_name: "Wayne", | ||
corrected_name: "Jim Wayne", | ||
email: "[email protected]") | ||
end | ||
|
||
let(:wizard) { FactoryBot.build(:register_mentor_wizard, current_step: :check_answers, store:) } | ||
let(:mentor) { wizard.mentor } | ||
|
||
|
@@ -55,4 +57,11 @@ | |
expect(rendered).to have_button('Confirm details') | ||
expect(rendered).to have_selector("form[action='#{confirm_details_path}']") | ||
end | ||
|
||
it "has change links" do | ||
render | ||
|
||
expect(rendered).to have_link("Change", href: schools_register_mentor_wizard_review_mentor_details_path) | ||
expect(rendered).to have_link("Change", href: schools_register_mentor_wizard_email_address_path) | ||
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 |
---|---|---|
|
@@ -3,8 +3,17 @@ | |
let(:continue_path) { schools_register_mentor_wizard_email_address_path } | ||
let(:mentor) { wizard.mentor } | ||
let(:title) { "What is Jim Waters's email address?" } | ||
let(:store) { double(trs_first_name: "John", trs_last_name: "Waters", corrected_name: "Jim Waters") } | ||
let(:email) { nil } | ||
let(:wizard) { FactoryBot.build(:register_mentor_wizard, current_step: :email_address, store:) } | ||
let(:store) do | ||
FactoryBot.build(:session_repository, | ||
trn: "1234567", | ||
trs_first_name: "John", | ||
trs_last_name: "Waters", | ||
trs_date_of_birth: "1950-01-01", | ||
corrected_name: "Jim Waters", | ||
email:) | ||
end | ||
|
||
before do | ||
assign(:wizard, wizard) | ||
|
@@ -22,6 +31,7 @@ | |
wizard.valid_step? | ||
render | ||
end | ||
|
||
it "prefixes the page with 'Error:' when the email is invalid" do | ||
expect(view.content_for(:page_title)).to start_with('Error:') | ||
end | ||
|
@@ -31,10 +41,23 @@ | |
end | ||
end | ||
|
||
it 'includes a back button that links to check mentor details of the journey' do | ||
render | ||
describe "back link" do | ||
before { render } | ||
|
||
expect(view.content_for(:backlink_or_breadcrumb)).to have_link('Back', href: back_path) | ||
context "when not checking answers" do | ||
it 'targets review mentor details page' do | ||
expect(view.content_for(:backlink_or_breadcrumb)).to have_link('Back', href: back_path) | ||
end | ||
end | ||
|
||
context "when checking answers" do | ||
let(:email) { '[email protected]' } | ||
let(:back_path) { schools_register_mentor_wizard_check_answers_path } | ||
|
||
it 'targets check your answers page' do | ||
expect(view.content_for(:backlink_or_breadcrumb)).to have_link('Back', href: back_path) | ||
end | ||
end | ||
end | ||
|
||
it 'includes a continue button that posts to the email address page' do | ||
|
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
let(:confirm_and_continue_path) { schools_register_mentor_wizard_review_mentor_details_path } | ||
let(:national_insurance_number) { "AD12345ED" } | ||
let(:title) { "Check mentor details" } | ||
let(:email) { nil } | ||
let(:store) do | ||
FactoryBot.build(:session_repository, | ||
trn: "1234567", | ||
|
@@ -14,7 +15,8 @@ | |
trs_date_of_birth: "1950-01-01", | ||
corrected_name: nil, | ||
date_of_birth:, | ||
national_insurance_number:) | ||
national_insurance_number:, | ||
email:) | ||
end | ||
let(:wizard) { FactoryBot.build(:register_mentor_wizard, current_step: :review_mentor_details, store:) } | ||
let(:mentor) { wizard.mentor } | ||
|
@@ -30,10 +32,23 @@ | |
expect(sanitize(view.content_for(:page_title))).to eql(sanitize(title)) | ||
end | ||
|
||
it 'includes a back button that links to trn and dob page of the journey' do | ||
render | ||
describe "back link" do | ||
before { render } | ||
|
||
context "when not checking answers" do | ||
it 'targets find mentor page' do | ||
expect(view.content_for(:backlink_or_breadcrumb)).to have_link('Back', href: back_path) | ||
end | ||
end | ||
|
||
expect(view.content_for(:backlink_or_breadcrumb)).to have_link('Back', href: back_path) | ||
context "when checking answers" do | ||
let(:email) { '[email protected]' } | ||
let(:back_path) { schools_register_mentor_wizard_check_answers_path } | ||
|
||
it 'targets check your answers page' do | ||
expect(view.content_for(:backlink_or_breadcrumb)).to have_link('Back', href: back_path) | ||
end | ||
end | ||
end | ||
|
||
it 'displays Name and TRN' do | ||
|
20 changes: 20 additions & 0 deletions
20
spec/wizards/schools/register_mentor_wizard/email_address_step_spec.rb
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,20 @@ | ||
describe Schools::RegisterMentorWizard::EmailAddressStep, type: :model do | ||
subject { described_class.new } | ||
|
||
describe 'validations' do | ||
it { is_expected.to allow_value('[email protected]').for(:email) } | ||
it { is_expected.not_to allow_value('invalid email').for(:email) } | ||
end | ||
|
||
describe '#next_step' do | ||
let(:wizard) do | ||
FactoryBot.build(:register_mentor_wizard, current_step: :email_address, step_params:) | ||
end | ||
|
||
let(:step_params) do | ||
ActionController::Parameters.new("email_address" => { "email" => '[email protected]' }) | ||
end | ||
|
||
it { expect(wizard.next_step).to eq(:check_answers) } | ||
end | ||
end |