-
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.
EY - enter email address, send email with code
- Loading branch information
Showing
18 changed files
with
192 additions
and
14 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
24 changes: 24 additions & 0 deletions
24
app/forms/journeys/early_years_payment/provider/email_address_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,24 @@ | ||
module Journeys | ||
module EarlyYearsPayment | ||
module Provider | ||
class EmailAddressForm < Form | ||
attribute :email_address, :string | ||
|
||
def save | ||
journey_session.answers.assign_attributes( | ||
email_address: email_address | ||
) | ||
journey_session.save! | ||
|
||
ClaimMailer.early_years_payment_provider_email(answers, otp_code).deliver_now | ||
end | ||
|
||
private | ||
|
||
def otp_code | ||
@otp_code ||= OneTimePassword::Generator.new.code | ||
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
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
2 changes: 1 addition & 1 deletion
2
app/models/policies/early_years_payment.rb → app/models/policies/early_years_payments.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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module Policies | ||
module EarlyYearsPayment | ||
module EarlyYearsPayments | ||
include BasePolicy | ||
extend self | ||
|
||
|
4 changes: 2 additions & 2 deletions
4
...licies/early_years_payment/eligibility.rb → ...icies/early_years_payments/eligibility.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
2 changes: 1 addition & 1 deletion
2
...ars_payment/policy_eligibility_checker.rb → ...rs_payments/policy_eligibility_checker.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
24 changes: 24 additions & 0 deletions
24
app/views/early_years_payment/provider/claims/check_your_email.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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<% content_for(:page_title, page_title(t("early_years_payment_provider.check_your_email_page.title"), journey: current_journey_routing_name)) %> | ||
|
||
<% @backlink_path = landing_page_path %> | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
<h1 class="govuk-heading-l"> | ||
Check your email | ||
</h1> | ||
|
||
<p class="govuk-body"> | ||
We have sent an email to <%= journey_session.answers.email_address %> | ||
</p> | ||
|
||
<p class="govuk-body"> | ||
Select the link in the email to log in or sign up. The link will expire in 15 minutes. | ||
</p> | ||
|
||
<p class="govuk-body"> | ||
If you do not receive the email, check your spam or junk folder. | ||
If you cannot find the email, <%= govuk_link_to "send another link", "" %> or <%= govuk_link_to "enter another email address", "" %>. | ||
</p> | ||
</div> | ||
</div> |
27 changes: 27 additions & 0 deletions
27
app/views/early_years_payment/provider/claims/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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<% content_for(:page_title, page_title(@form.t(:question), journey: current_journey_routing_name, show_error: @form.errors.any?)) %> | ||
|
||
<% @backlink_path = landing_page_path %> | ||
|
||
<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, html: { novalidate: false } do |f| %> | ||
<%= f.govuk_error_summary %> | ||
|
||
<h1 class="govuk-heading-l"> | ||
Enter your email address | ||
</h1> | ||
|
||
<p class="govuk-body"> | ||
You must use the email address previously provided to your local authority to access this service. | ||
</p> | ||
|
||
<%= f.govuk_text_field :email_address, | ||
autocomplete: "email", | ||
spellcheck: "false", | ||
label: { text: t("questions.email_address"), hidden: true } # label still read by screen readers | ||
%> | ||
|
||
<%= f.govuk_submit "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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1066,7 +1066,7 @@ en: | |
By submitting this you are confirming that, to the best of your knowledge, the details you are providing are | ||
correct. | ||
btn_text: Accept and send | ||
early_years_payment_provider: | ||
early_years_payment_provider: &early_years_payment_provider | ||
claim_description: for an early years financial incentive payment | ||
journey_name: Claim an early years financial incentive payment - provider | ||
landing_page: | ||
|
@@ -1080,6 +1080,14 @@ en: | |
notice. | ||
errors: | ||
presence: You must be able to confirm this information to continue | ||
email_address: | ||
question: "Enter your email address" | ||
check_your_email_page: | ||
title: Check your email | ||
early_years_payments: | ||
<<: *early_years_payment_provider | ||
claim_subject: "Early Years Payment" | ||
support_email_address: "[email protected]" | ||
activerecord: | ||
errors: | ||
models: | ||
|
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,4 @@ | ||
FactoryBot.define do | ||
factory :early_years_payments_eligibility, class: "Policies::EarlyYearsPayments::Eligibility" do | ||
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 |
---|---|---|
|
@@ -7,8 +7,26 @@ | |
visit landing_page_path(Journeys::EarlyYearsPayment::Provider::ROUTING_NAME) | ||
click_link "Start now" | ||
|
||
expect(page).to have_content("Declaration of Employee Consent") | ||
check "I confirm that I have obtained consent from my employee and have provided them with the relevant privacy notice." | ||
click_button "Continue" | ||
expect(page.title).to have_text(I18n.t("early_years_payment_provider.forms.email_address.question")) | ||
expect(page).to have_content("Enter your email address") | ||
fill_in "Email address", with: "[email protected]" | ||
click_on "Submit" | ||
|
||
expect(page.title).to have_text(I18n.t("early_years_payment_provider.check_your_email_page.title")) | ||
expect(page).to have_content("Check your email") | ||
expect(page).to have_content("We have sent an email to [email protected]") | ||
|
||
mail = ActionMailer::Base.deliveries.last | ||
mail_personalisation = mail[:personalisation].unparsed_value | ||
expect(mail_personalisation[:one_time_password]).to match(/\A\d{6}\Z/) | ||
|
||
# TODO - uncomment below when magic link functionality in place | ||
# expect(page).to have_content("Declaration of Employee Consent") | ||
# check "I confirm that I have obtained consent from my employee and have provided them with the relevant privacy notice." | ||
# click_button "Continue" | ||
end | ||
|
||
scenario "send another link" | ||
|
||
scenario "enter another email address" | ||
end |
30 changes: 30 additions & 0 deletions
30
spec/forms/journeys/early_years_payment/provider/email_address_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,30 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe Journeys::EarlyYearsPayment::Provider::EmailAddressForm do | ||
subject(:form) { described_class.new(journey:, journey_session:, params:) } | ||
|
||
let(:journey) { Journeys::EarlyYearsPayment::Provider } | ||
let(:journey_session) { build(:early_years_payment_provider_session) } | ||
# let(:params) { ActionController::Parameters.new({journey: "test-journey", slug: "test_slug", claim: claim_params}) } | ||
|
||
let(:params) do | ||
ActionController::Parameters.new(claim: {email_address: email_address}) | ||
end | ||
|
||
let(:email_address) { "[email protected]" } | ||
|
||
it { should have_attributes(email_address: email_address) } | ||
|
||
describe "#save" do | ||
subject { form.save } | ||
|
||
it { should be_truthy } | ||
|
||
it "sets the email address" do | ||
subject | ||
expect(journey_session.reload.answers.email_address).to( | ||
eq(email_address) | ||
) | ||
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 |
---|---|---|
|
@@ -308,6 +308,14 @@ class SomePolicy; end | |
}.to raise_error(ArgumentError, "Unknown claim policy: SomePolicy") | ||
end | ||
end | ||
|
||
describe "#early_years_payment_provider_email" do | ||
it "raises error" do | ||
expect { | ||
ClaimMailer.early_years_payment_provider_email(claim, nil).deliver! | ||
}.to raise_error(ArgumentError, "Unknown claim policy: SomePolicy") | ||
end | ||
end | ||
end | ||
|
||
describe "#email_verification" do | ||
|
@@ -335,4 +343,19 @@ class SomePolicy; end | |
end | ||
end | ||
end | ||
|
||
describe "#early_years_payment_provider_email" do | ||
let(:mail) { ClaimMailer.early_years_payment_provider_email(claim, one_time_password) } | ||
let(:one_time_password) { 123124 } | ||
let(:claim) { build(:claim, policy: policy, email_address: "[email protected]") } | ||
let(:policy) { Policies::EarlyYearsPayments } | ||
|
||
before { create(:journey_configuration, :early_years_payment_provider) } | ||
|
||
it "has personalisation keys for: one time password" do | ||
# TODO find correct email subject. Is subject used? or overriden on notify template? | ||
expect(mail[:personalisation].decoded).to eq("{:email_subject=>\"Early Years Payment\", :one_time_password=>123124}") | ||
expect(mail.body).to be_empty | ||
end | ||
end | ||
end |