From 5224dc49a9831eb1ca704cc2c0aa5e007448d33d Mon Sep 17 00:00:00 2001 From: Alkesh Vaghmaria Date: Wed, 21 Aug 2024 13:57:09 +0100 Subject: [PATCH 1/8] EY authenticated journey - check your answers page --- app/controllers/claims_controller.rb | 1 + app/controllers/claims_form_callbacks.rb | 4 + app/controllers/concerns/claim_submission.rb | 15 ++++ app/controllers/submissions_controller.rb | 11 +-- .../authenticated/check_your_answers_form.rb | 20 +++++ .../authenticated/claim_submission_form.rb | 2 +- app/models/claim.rb | 11 ++- .../provider/authenticated.rb | 3 +- .../authenticated/answers_presenter.rb | 81 +++++++++++++++++++ .../provider/authenticated/session_answers.rb | 5 ++ .../claims/check_your_answers.html.erb | 29 +++++++ .../authenticated/submissions/show.html.erb | 0 config/analytics.yml | 4 + config/analytics_blocklist.yml | 3 + config/locales/en.yml | 9 +++ ...40821110005_add_answer_fields_to_claims.rb | 7 ++ ...7_add_answer_fields_to_ey_eligibilities.rb | 8 ++ db/schema.rb | 7 ++ ..._payment_provider_authenticated_answers.rb | 24 ++++++ .../authenticated/changing_answers_spec.rb | 22 +++++ .../provider/authenticated/happy_path_spec.rb | 6 ++ .../submitter_name_omitted_spec.rb | 24 ++++++ .../check_your_answers_form_spec.rb | 39 +++++++++ .../claim_submission_form_spec.rb | 42 ++++++++++ spec/models/claim_spec.rb | 5 +- .../authenticated/answers_presenter_spec.rb | 55 +++++++++++++ .../eligible_ey_journey_authenticated.rb | 29 +++++++ 27 files changed, 450 insertions(+), 16 deletions(-) create mode 100644 app/controllers/concerns/claim_submission.rb create mode 100644 app/forms/journeys/early_years_payment/provider/authenticated/check_your_answers_form.rb create mode 100644 app/models/journeys/early_years_payment/provider/authenticated/answers_presenter.rb create mode 100644 app/views/early_years_payment/provider/authenticated/submissions/show.html.erb create mode 100644 db/migrate/20240821110005_add_answer_fields_to_claims.rb create mode 100644 db/migrate/20240821110027_add_answer_fields_to_ey_eligibilities.rb create mode 100644 spec/factories/journeys/early_years_payment/provider/authenticated/early_years_payment_provider_authenticated_answers.rb create mode 100644 spec/features/early_years_payment/provider/authenticated/changing_answers_spec.rb create mode 100644 spec/features/early_years_payment/provider/authenticated/submitter_name_omitted_spec.rb create mode 100644 spec/forms/journeys/early_years_payment/provider/authenticated/check_your_answers_form_spec.rb create mode 100644 spec/forms/journeys/early_years_payment/provider/authenticated/claim_submission_form_spec.rb create mode 100644 spec/models/journeys/early_years_payment/provider/authenticated/answers_presenter_spec.rb create mode 100644 spec/support/steps/eligible_ey_journey_authenticated.rb diff --git a/app/controllers/claims_controller.rb b/app/controllers/claims_controller.rb index 2813617f68..3bd1c38936 100644 --- a/app/controllers/claims_controller.rb +++ b/app/controllers/claims_controller.rb @@ -15,6 +15,7 @@ class ClaimsController < BasePublicController include AuthorisedSlugs include FormSubmittable include ClaimsFormCallbacks + include ClaimSubmission def existing_session @existing_session = journey_sessions.first diff --git a/app/controllers/claims_form_callbacks.rb b/app/controllers/claims_form_callbacks.rb index d5acf98d10..3afc56eef0 100644 --- a/app/controllers/claims_form_callbacks.rb +++ b/app/controllers/claims_form_callbacks.rb @@ -69,6 +69,10 @@ def check_your_email_after_form_save_success render("check_your_email") end + def check_your_answers_after_form_save_success + create_and_save_claim_form + end + private def set_backlink_override_to_current_slug diff --git a/app/controllers/concerns/claim_submission.rb b/app/controllers/concerns/claim_submission.rb new file mode 100644 index 0000000000..f72b63d045 --- /dev/null +++ b/app/controllers/concerns/claim_submission.rb @@ -0,0 +1,15 @@ +module ClaimSubmission + extend ActiveSupport::Concern + + def create_and_save_claim_form + @form = journey::ClaimSubmissionForm.new(journey_session: journey_session) + + if @form.save + session[:submitted_claim_id] = @form.claim.id + clear_claim_session + redirect_to claim_confirmation_path + else + render "claims/check_your_answers" + end + end +end diff --git a/app/controllers/submissions_controller.rb b/app/controllers/submissions_controller.rb index 45b3de0439..e4de544469 100644 --- a/app/controllers/submissions_controller.rb +++ b/app/controllers/submissions_controller.rb @@ -1,18 +1,11 @@ class SubmissionsController < BasePublicController include PartOfClaimJourney + include ClaimSubmission skip_before_action :send_unstarted_claimants_to_the_start, only: [:show] def create - @form = journey::ClaimSubmissionForm.new(journey_session: journey_session) - - if @form.save - session[:submitted_claim_id] = @form.claim.id - clear_claim_session - redirect_to claim_confirmation_path - else - render "claims/check_your_answers" - end + create_and_save_claim_form end def show diff --git a/app/forms/journeys/early_years_payment/provider/authenticated/check_your_answers_form.rb b/app/forms/journeys/early_years_payment/provider/authenticated/check_your_answers_form.rb new file mode 100644 index 0000000000..aabc2c5118 --- /dev/null +++ b/app/forms/journeys/early_years_payment/provider/authenticated/check_your_answers_form.rb @@ -0,0 +1,20 @@ +module Journeys + module EarlyYearsPayment + module Provider + module Authenticated + class CheckYourAnswersForm < Form + attribute :provider_contact_name + + validates :provider_contact_name, presence: {message: i18n_error_message(:valid)} + + def save + return false if invalid? + + journey_session.answers.assign_attributes(provider_contact_name:) + journey_session.save! + end + end + end + end + end +end diff --git a/app/forms/journeys/early_years_payment/provider/authenticated/claim_submission_form.rb b/app/forms/journeys/early_years_payment/provider/authenticated/claim_submission_form.rb index ca4302c99c..07ea12ec2a 100644 --- a/app/forms/journeys/early_years_payment/provider/authenticated/claim_submission_form.rb +++ b/app/forms/journeys/early_years_payment/provider/authenticated/claim_submission_form.rb @@ -6,7 +6,7 @@ class ClaimSubmissionForm < ::ClaimSubmissionBaseForm private def main_eligibility - @main_eligibility ||= Policies::EarlyYearsPayments::Eligibility.new + @main_eligibility ||= eligibilities.first end def calculate_award_amount(eligibility) diff --git a/app/models/claim.rb b/app/models/claim.rb index 0c8d418a54..c09e860c50 100644 --- a/app/models/claim.rb +++ b/app/models/claim.rb @@ -82,7 +82,10 @@ class Claim < ApplicationRecord identity_confirmed_with_onelogin: false, logged_in_with_onelogin: false, onelogin_credentials: true, - onelogin_user_info: true + onelogin_user_info: true, + paye_reference: true, + practitioner_email_address: true, + provider_contact_name: true }.freeze DECISION_DEADLINE = 12.weeks DECISION_DEADLINE_WARNING_POINT = 2.weeks @@ -142,11 +145,11 @@ class Claim < ApplicationRecord # TODO: remove when a form object is created for email-address validates :email_address, on: [:submit], presence: {message: "Enter an email address"} - validates :bank_sort_code, on: [:submit, :amendment], presence: {message: "Enter a sort code"} - validates :bank_account_number, on: [:submit, :amendment], presence: {message: "Enter an account number"} + validates :bank_sort_code, on: [:amendment], presence: {message: "Enter a sort code"} + validates :bank_account_number, on: [:amendment], presence: {message: "Enter an account number"} validates :building_society_roll_number, on: [:submit, :amendment], presence: {message: "Enter a roll number"}, if: -> { building_society? } - validates :payroll_gender, on: [:"payroll-gender-task", :submit], presence: {message: "You must select a gender that will be passed to HMRC"} + validates :payroll_gender, on: [:"payroll-gender-task"], presence: {message: "You must select a gender that will be passed to HMRC"} validate :bank_account_number_must_be_eight_digits validate :bank_sort_code_must_be_six_digits diff --git a/app/models/journeys/early_years_payment/provider/authenticated.rb b/app/models/journeys/early_years_payment/provider/authenticated.rb index 36e8af9cd1..ea61d8b3bd 100644 --- a/app/models/journeys/early_years_payment/provider/authenticated.rb +++ b/app/models/journeys/early_years_payment/provider/authenticated.rb @@ -18,7 +18,8 @@ module Authenticated "start-date" => StartDateForm, "child-facing" => ChildFacingForm, "returner" => ReturnerForm, - "employee-email" => EmployeeEmailForm + "employee-email" => EmployeeEmailForm, + "check-your-answers" => CheckYourAnswersForm } } START_WITH_MAGIC_LINK = true diff --git a/app/models/journeys/early_years_payment/provider/authenticated/answers_presenter.rb b/app/models/journeys/early_years_payment/provider/authenticated/answers_presenter.rb new file mode 100644 index 0000000000..0db28b2478 --- /dev/null +++ b/app/models/journeys/early_years_payment/provider/authenticated/answers_presenter.rb @@ -0,0 +1,81 @@ +module Journeys + module EarlyYearsPayment + module Provider + module Authenticated + class AnswersPresenter < BaseAnswersPresenter + include ActionView::Helpers::TranslationHelper + + def claim_answers + [].tap do |a| + a << nursery + a << paye_reference + a << employee_name + a << start_date + a << child_facing_confirmation_given + a << returner + a << employee_email_address + end + end + + private + + def nursery + [ + "Employee’s workplace", + EligibleEyProvider.find_by(urn: answers.nursery_urn).nursery_name, + "current-nursery" + ] + end + + def paye_reference + [ + "Employer’s PAYE reference number", + answers.paye_reference, + "paye-reference" + ] + end + + def employee_name + [ + "Employee's name", + [answers.first_name, answers.surname].join(" "), + "claimant-name" + ] + end + + def start_date + [ + "Employee's start date", + answers.start_date.to_fs(:long_date), + "start-date" + ] + end + + def child_facing_confirmation_given + [ + "Confirmation that employee spends most of their time in their job working directly with children", + (answers.child_facing_confirmation_given ? "Yes" : "No"), + "child-facing" + ] + end + + def returner + [ + "Confirmation that employee worked in an early years setting 6 months before the start date", + (answers.first_job_within_6_months ? "Yes" : "No"), + "returner" + ] + end + + def employee_email_address + [ + "Employee's email address", + answers.practitioner_email_address, + "employee-email" + ] + end + end + end + end + end +end diff --git a/app/models/journeys/early_years_payment/provider/authenticated/session_answers.rb b/app/models/journeys/early_years_payment/provider/authenticated/session_answers.rb index e3e877e138..e2465370f4 100644 --- a/app/models/journeys/early_years_payment/provider/authenticated/session_answers.rb +++ b/app/models/journeys/early_years_payment/provider/authenticated/session_answers.rb @@ -11,10 +11,15 @@ class SessionAnswers < Journeys::SessionAnswers attribute :first_job_within_6_months, :boolean attribute :start_date, :date attribute :practitioner_email_address + attribute :provider_contact_name def policy Policies::EarlyYearsPayments end + + def provide_mobile_number + false + end end end end diff --git a/app/views/early_years_payment/provider/authenticated/claims/check_your_answers.html.erb b/app/views/early_years_payment/provider/authenticated/claims/check_your_answers.html.erb index e69de29bb2..66bbeea317 100644 --- a/app/views/early_years_payment/provider/authenticated/claims/check_your_answers.html.erb +++ b/app/views/early_years_payment/provider/authenticated/claims/check_your_answers.html.erb @@ -0,0 +1,29 @@ +<% content_for( + :page_title, + page_title( + t("early_years_payment_provider_authenticated.check_your_answers.title"), + journey: current_journey_routing_name, + show_error: @form.errors.any? + ) +) %> + +
+
+

+ <%= t("early_years_payment_provider_authenticated.check_your_answers.title") %> +

+ + <%= render partial: "claims/check_your_answers_section", locals: {heading: nil, answers: journey.answers_for_claim(@form.journey_session).claim_answers} %> + <%= form_with model: @form, url: claim_path(current_journey_routing_name), method: :patch, builder: GOVUKDesignSystemFormBuilder::FormBuilder do |form| %> +

<%= t("early_years_payment_provider_authenticated.check_your_answers.heading_send_application") %>

+ +

<%= t("early_years_payment_provider_authenticated.check_your_answers.statement") %>

+ + <%= form.govuk_text_field :provider_contact_name, label: { text: "Your full name" }, spellcheck: "false" %> + +
+ <%= form.submit t("early_years_payment_provider_authenticated.check_your_answers.btn_text"), class: "govuk-button" %> +
+ <% end %> +
+
diff --git a/app/views/early_years_payment/provider/authenticated/submissions/show.html.erb b/app/views/early_years_payment/provider/authenticated/submissions/show.html.erb new file mode 100644 index 0000000000..e69de29bb2 diff --git a/config/analytics.yml b/config/analytics.yml index 1bb528b256..071d906938 100644 --- a/config/analytics.yml +++ b/config/analytics.yml @@ -306,5 +306,9 @@ shared: - updated_at :early_years_payment_eligibilities: - id + - nursery_urn + - start_date + - child_facing_confirmation_given + - first_job_within_6_months - created_at - updated_at diff --git a/config/analytics_blocklist.yml b/config/analytics_blocklist.yml index ff3998d33f..ac734c1f16 100644 --- a/config/analytics_blocklist.yml +++ b/config/analytics_blocklist.yml @@ -28,6 +28,9 @@ - teacher_id_user_info - onelogin_credentials - onelogin_user_info + - paye_reference + - practitioner_email_address + - provider_contact_name :claim_decisions: - trn - claimant_age diff --git a/config/locales/en.yml b/config/locales/en.yml index 46dd8210a0..57f082f177 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1202,6 +1202,15 @@ en: hint: We’ll use this to ask your employee to provide their payment details. errors: valid: Enter a valid email address + check_your_answers: + errors: + valid: You cannot submit this claim without providing your full name + check_your_answers: + title: Check your answers before submitting this claim + heading_send_application: Before submitting this claim + statement: + By submitting this claim you’re confirming that, to the best of your knowledge, the details you’re providing are correct. + btn_text: Accept and send early_years_payments: <<: *early_years_payment_provider_authenticated claim_subject: "Early Years Payment" diff --git a/db/migrate/20240821110005_add_answer_fields_to_claims.rb b/db/migrate/20240821110005_add_answer_fields_to_claims.rb new file mode 100644 index 0000000000..b3ae0b1a4d --- /dev/null +++ b/db/migrate/20240821110005_add_answer_fields_to_claims.rb @@ -0,0 +1,7 @@ +class AddAnswerFieldsToClaims < ActiveRecord::Migration[7.0] + def change + add_column :claims, :paye_reference, :string + add_column :claims, :practitioner_email_address, :string + add_column :claims, :provider_contact_name, :string + end +end diff --git a/db/migrate/20240821110027_add_answer_fields_to_ey_eligibilities.rb b/db/migrate/20240821110027_add_answer_fields_to_ey_eligibilities.rb new file mode 100644 index 0000000000..a5bf5500f4 --- /dev/null +++ b/db/migrate/20240821110027_add_answer_fields_to_ey_eligibilities.rb @@ -0,0 +1,8 @@ +class AddAnswerFieldsToEyEligibilities < ActiveRecord::Migration[7.0] + def change + add_column :early_years_payment_eligibilities, :nursery_urn, :string + add_column :early_years_payment_eligibilities, :start_date, :date + add_column :early_years_payment_eligibilities, :child_facing_confirmation_given, :boolean + add_column :early_years_payment_eligibilities, :first_job_within_6_months, :boolean + end +end diff --git a/db/schema.rb b/db/schema.rb index 58012cdeb7..4ed500a64b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -102,6 +102,9 @@ t.boolean "logged_in_with_onelogin" t.jsonb "onelogin_credentials", default: {} t.jsonb "onelogin_user_info", default: {} + t.string "paye_reference" + t.string "practitioner_email_address" + t.string "provider_contact_name" t.index ["academic_year"], name: "index_claims_on_academic_year" t.index ["created_at"], name: "index_claims_on_created_at" t.index ["eligibility_type", "eligibility_id"], name: "index_claims_on_eligibility_type_and_eligibility_id" @@ -183,6 +186,10 @@ create_table "early_years_payment_eligibilities", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.string "nursery_urn" + t.date "start_date" + t.boolean "child_facing_confirmation_given" + t.boolean "first_job_within_6_months" end create_table "eligible_ey_providers", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| diff --git a/spec/factories/journeys/early_years_payment/provider/authenticated/early_years_payment_provider_authenticated_answers.rb b/spec/factories/journeys/early_years_payment/provider/authenticated/early_years_payment_provider_authenticated_answers.rb new file mode 100644 index 0000000000..f2344fc4f0 --- /dev/null +++ b/spec/factories/journeys/early_years_payment/provider/authenticated/early_years_payment_provider_authenticated_answers.rb @@ -0,0 +1,24 @@ +FactoryBot.define do + factory :early_years_payment_provider_authenticated_answers, class: "Journeys::EarlyYearsPayment::Provider::Authenticated::SessionAnswers" do + trait :eligible do + academic_year { AcademicYear.current } + email_address { "provider@example.com" } + email_verified { true } + consent_given { true } + nursery_urn { create(:eligible_ey_provider).urn } + paye_reference { "123/A" } + first_name { "John" } + surname { "Doe" } + start_date { Date.parse("1/1/2024") } + child_facing_confirmation_given { true } + first_job_within_6_months { true } + practitioner_email_address { "johndoe@example.com" } + provide_mobile_number { false } + end + + trait :submittable do + eligible + provider_contact_name { "John Doe" } + end + end +end diff --git a/spec/features/early_years_payment/provider/authenticated/changing_answers_spec.rb b/spec/features/early_years_payment/provider/authenticated/changing_answers_spec.rb new file mode 100644 index 0000000000..3b97d2104e --- /dev/null +++ b/spec/features/early_years_payment/provider/authenticated/changing_answers_spec.rb @@ -0,0 +1,22 @@ +require "rails_helper" + +RSpec.feature "Early years payment provider" do + let(:email_address) { "johndoe@example.com" } + let(:journey_session) { Journeys::EarlyYearsPayment::Provider::Authenticated::Session.last } + let(:mail) { ActionMailer::Base.deliveries.last } + let(:magic_link) { mail[:personalisation].unparsed_value[:magic_link] } + let!(:nursery) { create(:eligible_ey_provider, primary_key_contact_email_address: email_address) } + + scenario "changing answers on the check-your-answers page" do + when_early_years_payment_provider_authenticated_journey_configuration_exists + when_early_years_payment_provider_start_journey_completed + when_early_years_payment_provider_authenticated_journey_ready_to_submit + + find("a[href='#{claim_path(Journeys::EarlyYearsPayment::Provider::Authenticated::ROUTING_NAME, "paye-reference")}']").click + expect(page).to have_content("What is #{nursery.nursery_name}’s employer PAYE reference?") + fill_in "claim-paye-reference-field", with: "123/A" + click_button "Continue" + + expect(page.current_path).to eq "/early-years-payment-provider/check-your-answers" + end +end diff --git a/spec/features/early_years_payment/provider/authenticated/happy_path_spec.rb b/spec/features/early_years_payment/provider/authenticated/happy_path_spec.rb index a7e2d5252a..1a7f521b02 100644 --- a/spec/features/early_years_payment/provider/authenticated/happy_path_spec.rb +++ b/spec/features/early_years_payment/provider/authenticated/happy_path_spec.rb @@ -53,6 +53,12 @@ click_button "Continue" expect(page.current_path).to eq "/early-years-payment-provider/check-your-answers" + expect(page).to have_content("Check your answers before submitting this claim") + fill_in "claim-provider-contact-name-field", with: "John Doe" + click_button "Accept and send" + + expect(page.current_path).to eq claim_confirmation_path(Journeys::EarlyYearsPayment::Provider::Authenticated::ROUTING_NAME) + expect(Claim.last.provider_contact_name).to eq "John Doe" end scenario "using magic link after having completed some of the journey" do diff --git a/spec/features/early_years_payment/provider/authenticated/submitter_name_omitted_spec.rb b/spec/features/early_years_payment/provider/authenticated/submitter_name_omitted_spec.rb new file mode 100644 index 0000000000..31c3b0aa01 --- /dev/null +++ b/spec/features/early_years_payment/provider/authenticated/submitter_name_omitted_spec.rb @@ -0,0 +1,24 @@ +require "rails_helper" + +RSpec.feature "Early years payment provider" do + let(:email_address) { "johndoe@example.com" } + let(:journey_session) { Journeys::EarlyYearsPayment::Provider::Authenticated::Session.last } + let(:mail) { ActionMailer::Base.deliveries.last } + let(:magic_link) { mail[:personalisation].unparsed_value[:magic_link] } + let!(:nursery) { create(:eligible_ey_provider, primary_key_contact_email_address: email_address) } + + scenario "when the submitter name is omitted on the check-your-answers page" do + when_early_years_payment_provider_authenticated_journey_configuration_exists + when_early_years_payment_provider_start_journey_completed + when_early_years_payment_provider_authenticated_journey_ready_to_submit + click_button "Accept and send" + + expect(page.current_path).to eq "/early-years-payment-provider/check-your-answers" + expect(page).to have_content "You cannot submit this claim without providing your full name" + + fill_in "claim-provider-contact-name-field-error", with: "John Doe" + click_button "Accept and send" + + expect(page.current_path).to eq claim_confirmation_path(Journeys::EarlyYearsPayment::Provider::Authenticated::ROUTING_NAME) + end +end diff --git a/spec/forms/journeys/early_years_payment/provider/authenticated/check_your_answers_form_spec.rb b/spec/forms/journeys/early_years_payment/provider/authenticated/check_your_answers_form_spec.rb new file mode 100644 index 0000000000..04d8f2ffc2 --- /dev/null +++ b/spec/forms/journeys/early_years_payment/provider/authenticated/check_your_answers_form_spec.rb @@ -0,0 +1,39 @@ +require "rails_helper" + +RSpec.describe Journeys::EarlyYearsPayment::Provider::Authenticated::CheckYourAnswersForm, type: :model do + let(:journey) { Journeys::EarlyYearsPayment::Provider::Authenticated } + let(:journey_session) { create(:early_years_payment_provider_authenticated_session) } + let(:provider_contact_name) { nil } + + let(:params) do + ActionController::Parameters.new( + claim: { + provider_contact_name: + } + ) + end + + subject do + described_class.new(journey_session:, journey:, params:) + end + + describe "validations" do + it do + is_expected.not_to( + allow_value(provider_contact_name) + .for(:provider_contact_name) + .with_message("You cannot submit this claim without providing your full name") + ) + end + end + + describe "#save" do + let(:provider_contact_name) { "John Doe" } + + it "updates the journey session" do + expect { expect(subject.save).to be(true) }.to( + change { journey_session.reload.answers.provider_contact_name }.to("John Doe") + ) + end + end +end diff --git a/spec/forms/journeys/early_years_payment/provider/authenticated/claim_submission_form_spec.rb b/spec/forms/journeys/early_years_payment/provider/authenticated/claim_submission_form_spec.rb new file mode 100644 index 0000000000..539a5d3235 --- /dev/null +++ b/spec/forms/journeys/early_years_payment/provider/authenticated/claim_submission_form_spec.rb @@ -0,0 +1,42 @@ +require "rails_helper" + +RSpec.describe Journeys::EarlyYearsPayment::Provider::Authenticated::ClaimSubmissionForm do + before do + create(:journey_configuration, :early_years_payment_provider_authenticated) + end + + let(:journey) { Journeys::EarlyYearsPayment::Provider::Authenticated } + + let(:journey_session) { create(:early_years_payment_provider_authenticated_session, answers: answers) } + let(:form) { described_class.new(journey_session: journey_session) } + + describe "#save" do + subject { form.save } + + let(:claim) { form.claim } + let(:eligibility) { claim.eligibility } + let(:answers) { build(:early_years_payment_provider_authenticated_answers, :submittable) } + + it { is_expected.to be_truthy } + + it "saves some answers into the Claim model" do + subject + expect(claim.email_address).to eq answers.email_address + expect(claim.submitted_at).to be_present + expect(claim.eligibility_type).to eq "Policies::EarlyYearsPayments::Eligibility" + expect(claim.first_name).to eq answers.first_name + expect(claim.surname).to eq answers.surname + expect(claim.paye_reference).to eq answers.paye_reference + expect(claim.practitioner_email_address).to eq answers.practitioner_email_address + expect(claim.provider_contact_name).to eq "John Doe" + end + + it "saves some answers into the Eligibility model" do + subject + expect(eligibility.nursery_urn).to eq answers.nursery_urn + expect(eligibility.child_facing_confirmation_given).to eq answers.child_facing_confirmation_given + expect(eligibility.first_job_within_6_months).to eq answers.first_job_within_6_months + expect(eligibility.start_date).to eq answers.start_date + end + end +end diff --git a/spec/models/claim_spec.rb b/spec/models/claim_spec.rb index 07797e91a1..8ff0154012 100644 --- a/spec/models/claim_spec.rb +++ b/spec/models/claim_spec.rb @@ -604,7 +604,10 @@ :qualifications_details_check, :column_to_remove_teacher_reference_number, :onelogin_credentials, - :onelogin_user_info + :onelogin_user_info, + :paye_reference, + :practitioner_email_address, + :provider_contact_name ]) end end diff --git a/spec/models/journeys/early_years_payment/provider/authenticated/answers_presenter_spec.rb b/spec/models/journeys/early_years_payment/provider/authenticated/answers_presenter_spec.rb new file mode 100644 index 0000000000..2b99893227 --- /dev/null +++ b/spec/models/journeys/early_years_payment/provider/authenticated/answers_presenter_spec.rb @@ -0,0 +1,55 @@ +require "rails_helper" + +RSpec.describe Journeys::EarlyYearsPayment::Provider::Authenticated::AnswersPresenter do + let(:journey_session) do + create(:early_years_payment_provider_authenticated_session, answers: answers) + end + + let(:presenter) { described_class.new(journey_session) } + + describe "#claim_answers" do + subject { presenter.claim_answers } + + let(:answers) { build(:early_years_payment_provider_authenticated_answers, :eligible) } + + it do + is_expected.to include( + [ + "Employee’s workplace", + EligibleEyProvider.first.nursery_name, + "current-nursery" + ], + [ + "Employer’s PAYE reference number", + "123/A", + "paye-reference" + ], + [ + "Employee's name", + "John Doe", + "claimant-name" + ], + [ + "Employee's start date", + "1 January 2024", + "start-date" + ], + [ + "Confirmation that employee spends most of their time in their job working directly with children", + "Yes", + "child-facing" + ], + [ + "Confirmation that employee worked in an early years setting 6 months before the start date", + "Yes", + "returner" + ], + [ + "Employee's email address", + "johndoe@example.com", + "employee-email" + ] + ) + end + end +end diff --git a/spec/support/steps/eligible_ey_journey_authenticated.rb b/spec/support/steps/eligible_ey_journey_authenticated.rb new file mode 100644 index 0000000000..63342d57d5 --- /dev/null +++ b/spec/support/steps/eligible_ey_journey_authenticated.rb @@ -0,0 +1,29 @@ +def when_early_years_payment_provider_authenticated_journey_ready_to_submit + visit magic_link + check "I confirm that I have obtained consent from my employee and have provided them with the relevant privacy notice." + click_button "Continue" + + choose nursery.nursery_name + click_button "Continue" + + fill_in "claim-paye-reference-field", with: "123/123456SE90" + click_button "Continue" + + fill_in "First name", with: "Bobby" + fill_in "Last name", with: "Bobberson" + click_button "Continue" + + fill_in("Day", with: "1") + fill_in("Month", with: "12") + fill_in("Year", with: "2024") + click_button "Continue" + + check "I confirm that at least 70% of Bobby’s time in their job is spent working directly with children." + click_button "Continue" + + choose "No" + click_button "Continue" + + fill_in "claim-practitioner-email-address-field", with: "practitioner@example.com" + click_button "Continue" +end From 5e07c241f74bbb39001c6b345203e77196d41cae Mon Sep 17 00:00:00 2001 From: Alkesh Vaghmaria Date: Thu, 22 Aug 2024 16:06:49 +0100 Subject: [PATCH 2/8] use correct apostrophes --- .../provider/authenticated/answers_presenter.rb | 6 +++--- .../provider/authenticated/answers_presenter_spec.rb | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/models/journeys/early_years_payment/provider/authenticated/answers_presenter.rb b/app/models/journeys/early_years_payment/provider/authenticated/answers_presenter.rb index 0db28b2478..fbeaf33545 100644 --- a/app/models/journeys/early_years_payment/provider/authenticated/answers_presenter.rb +++ b/app/models/journeys/early_years_payment/provider/authenticated/answers_presenter.rb @@ -37,7 +37,7 @@ def paye_reference def employee_name [ - "Employee's name", + "Employee’s name", [answers.first_name, answers.surname].join(" "), "claimant-name" ] @@ -45,7 +45,7 @@ def employee_name def start_date [ - "Employee's start date", + "Employee’s start date", answers.start_date.to_fs(:long_date), "start-date" ] @@ -69,7 +69,7 @@ def returner def employee_email_address [ - "Employee's email address", + "Employee’s email address", answers.practitioner_email_address, "employee-email" ] diff --git a/spec/models/journeys/early_years_payment/provider/authenticated/answers_presenter_spec.rb b/spec/models/journeys/early_years_payment/provider/authenticated/answers_presenter_spec.rb index 2b99893227..77c7cf1ded 100644 --- a/spec/models/journeys/early_years_payment/provider/authenticated/answers_presenter_spec.rb +++ b/spec/models/journeys/early_years_payment/provider/authenticated/answers_presenter_spec.rb @@ -25,12 +25,12 @@ "paye-reference" ], [ - "Employee's name", + "Employee’s name", "John Doe", "claimant-name" ], [ - "Employee's start date", + "Employee’s start date", "1 January 2024", "start-date" ], @@ -45,7 +45,7 @@ "returner" ], [ - "Employee's email address", + "Employee’s email address", "johndoe@example.com", "employee-email" ] From 58e4be88daeaa28c85f7ae604ead48d6e38f6ba8 Mon Sep 17 00:00:00 2001 From: Alkesh Vaghmaria Date: Thu, 22 Aug 2024 16:45:30 +0100 Subject: [PATCH 3/8] add error banner to top of check-your-answers page --- .../provider/authenticated/claims/check_your_answers.html.erb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/views/early_years_payment/provider/authenticated/claims/check_your_answers.html.erb b/app/views/early_years_payment/provider/authenticated/claims/check_your_answers.html.erb index 66bbeea317..e87d45e799 100644 --- a/app/views/early_years_payment/provider/authenticated/claims/check_your_answers.html.erb +++ b/app/views/early_years_payment/provider/authenticated/claims/check_your_answers.html.erb @@ -9,6 +9,9 @@
+ <% if @form.errors.any? %> + <%= render("shared/error_summary", instance: @form, errored_field_id_overrides: {"provider_contact_name":"claim-provider-contact-name-field-error"}) %> + <% end %>

<%= t("early_years_payment_provider_authenticated.check_your_answers.title") %>

From a1339bcd64a5671c5c1b5f4ea118487c23e34ea6 Mon Sep 17 00:00:00 2001 From: Alkesh Vaghmaria Date: Tue, 27 Aug 2024 09:46:44 +0100 Subject: [PATCH 4/8] add error banner to all pages --- .../provider/authenticated/claims/child_facing.html.erb | 1 + .../provider/authenticated/claims/consent.html.erb | 1 + .../provider/authenticated/claims/employee_email.html.erb | 2 ++ .../provider/authenticated/claims/paye_reference.html.erb | 2 ++ 4 files changed, 6 insertions(+) diff --git a/app/views/early_years_payment/provider/authenticated/claims/child_facing.html.erb b/app/views/early_years_payment/provider/authenticated/claims/child_facing.html.erb index 639be5c1e6..19624cd900 100644 --- a/app/views/early_years_payment/provider/authenticated/claims/child_facing.html.erb +++ b/app/views/early_years_payment/provider/authenticated/claims/child_facing.html.erb @@ -3,6 +3,7 @@
<%= form_with model: @form, url: claim_path(current_journey_routing_name), method: :patch, builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> + <%= f.govuk_error_summary %> <%= f.govuk_check_boxes_fieldset :child_facing_confirmation_given, multiple: false, legend: { text: @form.t(:question, first_name: answers.first_name), tag: "h1", size: "l" }, hint: -> do %>
diff --git a/app/views/early_years_payment/provider/authenticated/claims/consent.html.erb b/app/views/early_years_payment/provider/authenticated/claims/consent.html.erb index e98d5426f7..f3ca0aa828 100644 --- a/app/views/early_years_payment/provider/authenticated/claims/consent.html.erb +++ b/app/views/early_years_payment/provider/authenticated/claims/consent.html.erb @@ -3,6 +3,7 @@
<%= 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 %> <%= f.govuk_check_boxes_fieldset :consent_given, multiple: false, legend: { text: @form.t(:question), tag: "h1", size: "l" }, hint: -> do %>

diff --git a/app/views/early_years_payment/provider/authenticated/claims/employee_email.html.erb b/app/views/early_years_payment/provider/authenticated/claims/employee_email.html.erb index 1978a95cf6..88c66c6529 100644 --- a/app/views/early_years_payment/provider/authenticated/claims/employee_email.html.erb +++ b/app/views/early_years_payment/provider/authenticated/claims/employee_email.html.erb @@ -3,6 +3,8 @@

<%= form_with model: @form, url: claim_path(current_journey_routing_name), method: :patch, builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> + <%= f.govuk_error_summary %> + <%= 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" %> diff --git a/app/views/early_years_payment/provider/authenticated/claims/paye_reference.html.erb b/app/views/early_years_payment/provider/authenticated/claims/paye_reference.html.erb index b059e83eac..909cc1361f 100644 --- a/app/views/early_years_payment/provider/authenticated/claims/paye_reference.html.erb +++ b/app/views/early_years_payment/provider/authenticated/claims/paye_reference.html.erb @@ -3,6 +3,8 @@
<%= form_with model: @form, url: claim_path(current_journey_routing_name), method: :patch, builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> + <%= f.govuk_error_summary %> + <%= f.govuk_text_field :paye_reference, label: { text: @form.t(:question, nursery_name: @form.nursery_name), tag: "h1", size: "l" }, hint: { text: @form.t(:hint) }, From 277de18d6beca74901d72d52de75bb36703b4e8e Mon Sep 17 00:00:00 2001 From: Alkesh Vaghmaria Date: Wed, 28 Aug 2024 13:53:26 +0100 Subject: [PATCH 5/8] fix spec - start date should be in the past --- spec/support/steps/eligible_ey_journey_authenticated.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/spec/support/steps/eligible_ey_journey_authenticated.rb b/spec/support/steps/eligible_ey_journey_authenticated.rb index 63342d57d5..805648d7fa 100644 --- a/spec/support/steps/eligible_ey_journey_authenticated.rb +++ b/spec/support/steps/eligible_ey_journey_authenticated.rb @@ -13,9 +13,10 @@ def when_early_years_payment_provider_authenticated_journey_ready_to_submit fill_in "Last name", with: "Bobberson" click_button "Continue" - fill_in("Day", with: "1") - fill_in("Month", with: "12") - fill_in("Year", with: "2024") + date = Date.yesterday + fill_in("Day", with: date.day) + fill_in("Month", with: date.month) + fill_in("Year", with: date.year) click_button "Continue" check "I confirm that at least 70% of Bobby’s time in their job is spent working directly with children." From e045ab4801bd78ba79cd1b8e6262cae681fe8ad2 Mon Sep 17 00:00:00 2001 From: Abigail McPhillips Date: Thu, 22 Aug 2024 14:31:50 +0100 Subject: [PATCH 6/8] Submissions /show page for EY --- .../authenticated/submissions/show.html.erb | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/app/views/early_years_payment/provider/authenticated/submissions/show.html.erb b/app/views/early_years_payment/provider/authenticated/submissions/show.html.erb index e69de29bb2..bccaa2110b 100644 --- a/app/views/early_years_payment/provider/authenticated/submissions/show.html.erb +++ b/app/views/early_years_payment/provider/authenticated/submissions/show.html.erb @@ -0,0 +1,37 @@ +<% content_for(:page_title, page_title("Claim submitted", journey: current_journey_routing_name)) %> + +
+
+ +
+

Claim submitted

+ +
+ Your claim reference
+ <%= submitted_claim.reference %> +
+
+ +

+ You’ve successfully submitted a claim for an early years financial + incentive payment on behalf of <%= submitted_claim.first_name %> <%= submitted_claim.surname %>. +

+ +

+ We’ve sent a confirmation email to <%= submitted_claim.email_address %>. +

+ +

What happens next

+ +

+ We’ll send an email to your employee asking for them to provide some + further information. We’ll also ask them to provide their payment details. +

+ +

+ For more information, read more about the + <%= govuk_link_to("early years financial incentive", "#") %>. +

+
+
+ From 5e93ba2d81968c81db6cd570dc3331ecd58565ef Mon Sep 17 00:00:00 2001 From: Abigail McPhillips Date: Fri, 23 Aug 2024 10:52:01 +0100 Subject: [PATCH 7/8] Add claim submitted template ID --- app/mailers/application_mailer.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 1f696937f3..e1f072fc09 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -32,6 +32,7 @@ class ApplicationMailer < Mail::Notify::Mailer CLAIM_REJECTED_NOTIFY_TEMPLATE_ID: "1edc468c-a1bf-4bea-bb79-042740cd8547".freeze } EARLY_YEARS_PAYMENTS = { - CLAIM_PROVIDER_EMAIL_TEMPLATE_ID: "e0b78a08-601b-40ba-a97f-61fb00a7c951".freeze + CLAIM_PROVIDER_EMAIL_TEMPLATE_ID: "e0b78a08-601b-40ba-a97f-61fb00a7c951".freeze, + CLAIM_RECEIVED_NOTIFY_TEMPLATE_ID: "149c5999-12fb-4b99-aff5-23a7c3302783".freeze } end From 1757652839adea33869424265d57ea7157044631 Mon Sep 17 00:00:00 2001 From: Abigail McPhillips Date: Fri, 23 Aug 2024 10:57:39 +0100 Subject: [PATCH 8/8] Extend happy path spec --- .../provider/authenticated/happy_path_spec.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spec/features/early_years_payment/provider/authenticated/happy_path_spec.rb b/spec/features/early_years_payment/provider/authenticated/happy_path_spec.rb index 1a7f521b02..3cba38300a 100644 --- a/spec/features/early_years_payment/provider/authenticated/happy_path_spec.rb +++ b/spec/features/early_years_payment/provider/authenticated/happy_path_spec.rb @@ -58,7 +58,10 @@ click_button "Accept and send" expect(page.current_path).to eq claim_confirmation_path(Journeys::EarlyYearsPayment::Provider::Authenticated::ROUTING_NAME) - expect(Claim.last.provider_contact_name).to eq "John Doe" + + claim = Claim.last + expect(claim.provider_contact_name).to eq "John Doe" + expect(page).to have_content(claim.reference) end scenario "using magic link after having completed some of the journey" do