-
Notifications
You must be signed in to change notification settings - Fork 16
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 #3105 from DFE-Digital/LUPEYALPHA-769-practitioner…
…-email-address [LUPEYALPHA-769] practitioner email address
- Loading branch information
Showing
10 changed files
with
86 additions
and
3 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
app/forms/journeys/early_years_payment/provider/authenticated/employee_email_form.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 @@ | ||
module Journeys | ||
module EarlyYearsPayment | ||
module Provider | ||
module Authenticated | ||
class EmployeeEmailForm < Form | ||
attribute :practitioner_email_address | ||
|
||
validates :practitioner_email_address, presence: {message: i18n_error_message(:valid)} | ||
|
||
def save | ||
return false if invalid? | ||
|
||
journey_session.answers.assign_attributes(practitioner_email_address:) | ||
journey_session.save! | ||
end | ||
end | ||
end | ||
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
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
Empty file.
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 @@ | ||
<% content_for(:page_title, page_title(@form.t(:question, first_name: answers.first_name), journey: current_journey_routing_name, show_error: @form.errors.any?)) %> | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
<%= form_with model: @form, url: claim_path(current_journey_routing_name), method: :patch, builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> | ||
<%= f.govuk_text_field :practitioner_email_address, | ||
label: { text: @form.t(:question, first_name: answers.first_name), tag: "h1", size: "l" }, | ||
hint: { text: @form.t(:hint) }, spellcheck: "false" %> | ||
<%= f.govuk_submit %> | ||
<% end %> | ||
</div> | ||
</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
33 changes: 33 additions & 0 deletions
33
spec/forms/journeys/early_years_payment/provider/authenticated/employee_email_form_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,33 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe Journeys::EarlyYearsPayment::Provider::Authenticated::EmployeeEmailForm, type: :model do | ||
let(:journey) { Journeys::EarlyYearsPayment::Provider::Authenticated } | ||
let(:journey_session) { create(:early_years_payment_provider_authenticated_session) } | ||
let(:practitioner_email_address) { nil } | ||
|
||
let(:params) do | ||
ActionController::Parameters.new( | ||
claim: { | ||
practitioner_email_address: | ||
} | ||
) | ||
end | ||
|
||
subject do | ||
described_class.new(journey_session:, journey:, params:) | ||
end | ||
|
||
describe "validations" do | ||
it { should validate_presence_of(:practitioner_email_address).with_message("Enter a valid email address") } | ||
end | ||
|
||
describe "#save" do | ||
let(:practitioner_email_address) { "practitioner@example.com" } | ||
|
||
it "updates the journey session" do | ||
expect { subject.save }.to( | ||
change { journey_session.answers.practitioner_email_address }.to(practitioner_email_address) | ||
) | ||
end | ||
end | ||
end |