diff --git a/app/forms/claim_submission_base_form.rb b/app/forms/claim_submission_base_form.rb index 87a76f58c0..0fc29a2c39 100644 --- a/app/forms/claim_submission_base_form.rb +++ b/app/forms/claim_submission_base_form.rb @@ -21,7 +21,6 @@ def save ApplicationRecord.transaction do set_attributes_for_claim_submission - main_eligibility.save! claim.save! end @@ -35,20 +34,25 @@ def save delegate :answers, to: :journey_session - def build_claim - claim = Claim.new - - claim.eligibility = main_eligibility - - claim.started_at = journey_session.created_at + def main_eligibility + @main_eligibility ||= eligibilities.first + end - answers.attributes.each do |name, value| - if claim.respond_to?(:"#{name}=") - claim.public_send(:"#{name}=", value) + def build_claim + new_or_find_claim.tap do |claim| + claim.eligibility ||= main_eligibility + claim.started_at = journey_session.created_at + + answers.attributes.each do |name, value| + if claim.respond_to?(:"#{name}=") + claim.public_send(:"#{name}=", value) + end end end + end - claim + def new_or_find_claim + Claim.new end def eligibilities @@ -71,7 +75,11 @@ def set_eligibility_attributes(eligibility) def set_attributes_for_claim_submission claim.journey_session = journey_session claim.policy_options_provided = generate_policy_options_provided - claim.reference = generate_reference + claim.reference ||= generate_reference + set_submitted_at_attributes + end + + def set_submitted_at_attributes claim.submitted_at = Time.zone.now end @@ -121,7 +129,7 @@ def mobile_number_verified? end def claim_is_eligible - if main_eligibility.policy::PolicyEligibilityChecker.new(answers: answers).ineligible? + if claim.eligibility.policy::PolicyEligibilityChecker.new(answers: answers).ineligible? errors.add(:base, i18n_errors_path(:ineligible)) end end diff --git a/app/forms/journeys/early_years_payment/practitioner/claim_submission_form.rb b/app/forms/journeys/early_years_payment/practitioner/claim_submission_form.rb index fe0eaf093b..b5d6fc8c9c 100644 --- a/app/forms/journeys/early_years_payment/practitioner/claim_submission_form.rb +++ b/app/forms/journeys/early_years_payment/practitioner/claim_submission_form.rb @@ -2,10 +2,6 @@ module Journeys module EarlyYearsPayment module Practitioner class ClaimSubmissionForm < ::ClaimSubmissionBaseForm - def main_eligibility - @main_eligibility ||= eligibilities.detect { |e| e.policy == main_policy } - end - def calculate_award_amount(eligibility) 0 end @@ -13,6 +9,21 @@ def calculate_award_amount(eligibility) def main_policy Policies::EarlyYearsPayments end + + private + + def generate_policy_options_provided + [] + end + + def new_or_find_claim + Claim.find_by(reference: journey_session.answers.reference_number) || Claim.new + end + + def set_submitted_at_attributes + claim.eligibility.practitioner_claim_started_at = journey_session.created_at + claim.submitted_at = Time.zone.now + end end end end diff --git a/app/forms/journeys/early_years_payment/practitioner/find_reference_form.rb b/app/forms/journeys/early_years_payment/practitioner/find_reference_form.rb index 9a3b67b035..02d60c8c4e 100644 --- a/app/forms/journeys/early_years_payment/practitioner/find_reference_form.rb +++ b/app/forms/journeys/early_years_payment/practitioner/find_reference_form.rb @@ -18,7 +18,7 @@ def save reference_number:, start_email: email, reference_number_found: existing_claim.present?, - claim_already_submitted: existing_claim&.eligibility&.practitioner_claim_submitted?, + claim_already_submitted: existing_claim&.submitted?, nursery_name: existing_claim&.eligibility&.eligible_ey_provider&.nursery_name ) journey_session.save! 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 e75cad2649..fc32ad2e3e 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 @@ -13,10 +13,6 @@ def save private - def main_eligibility - @main_eligibility ||= eligibilities.first - end - def calculate_award_amount(eligibility) # NOOP # This is just for compatibility with the AdditionalPaymentsForTeaching @@ -26,6 +22,10 @@ def calculate_award_amount(eligibility) def generate_policy_options_provided [] end + + def set_submitted_at_attributes + claim.eligibility.provider_claim_submitted_at = Time.zone.now + end end end end diff --git a/app/forms/journeys/early_years_payment/provider/start/claim_submission_form.rb b/app/forms/journeys/early_years_payment/provider/start/claim_submission_form.rb index 9c32da2e19..50216c3274 100644 --- a/app/forms/journeys/early_years_payment/provider/start/claim_submission_form.rb +++ b/app/forms/journeys/early_years_payment/provider/start/claim_submission_form.rb @@ -5,10 +5,6 @@ module Start class ClaimSubmissionForm < ::ClaimSubmissionBaseForm private - def main_eligibility - @main_eligibility ||= Policies::EarlyYearsPayments::Eligibility.new - end - def calculate_award_amount(eligibility) # NOOP # This is just for compatibility with the AdditionalPaymentsForTeaching diff --git a/app/forms/journeys/further_education_payments/claim_submission_form.rb b/app/forms/journeys/further_education_payments/claim_submission_form.rb index da48296a04..24d7d9763f 100644 --- a/app/forms/journeys/further_education_payments/claim_submission_form.rb +++ b/app/forms/journeys/further_education_payments/claim_submission_form.rb @@ -19,10 +19,6 @@ def save private - def main_eligibility - @main_eligibility ||= eligibilities.first - end - def calculate_award_amount(eligibility) # NOOP # This is just for compatibility with the AdditionalPaymentsForTeaching diff --git a/app/forms/journeys/get_a_teacher_relocation_payment/claim_submission_form.rb b/app/forms/journeys/get_a_teacher_relocation_payment/claim_submission_form.rb index a9fad9c3db..a04b978e33 100644 --- a/app/forms/journeys/get_a_teacher_relocation_payment/claim_submission_form.rb +++ b/app/forms/journeys/get_a_teacher_relocation_payment/claim_submission_form.rb @@ -3,10 +3,6 @@ module GetATeacherRelocationPayment class ClaimSubmissionForm < ::ClaimSubmissionBaseForm private - def main_eligibility - @main_eligibility ||= eligibilities.first - end - def calculate_award_amount(eligibility) eligibility.award_amount = Policies::InternationalRelocationPayments.award_amount end diff --git a/app/forms/journeys/teacher_student_loan_reimbursement/claim_submission_form.rb b/app/forms/journeys/teacher_student_loan_reimbursement/claim_submission_form.rb index 2f1715da34..982d1f44f3 100644 --- a/app/forms/journeys/teacher_student_loan_reimbursement/claim_submission_form.rb +++ b/app/forms/journeys/teacher_student_loan_reimbursement/claim_submission_form.rb @@ -3,10 +3,6 @@ module TeacherStudentLoanReimbursement class ClaimSubmissionForm < ::ClaimSubmissionBaseForm private - def main_eligibility - @main_eligibility ||= eligibilities.first - end - def calculate_award_amount(eligibility) # NOOP # This is just for compatibility with the AdditionalPaymentsForTeaching diff --git a/app/jobs/claim_verifier_job.rb b/app/jobs/claim_verifier_job.rb index d876bbfbfa..1cd4f5e596 100644 --- a/app/jobs/claim_verifier_job.rb +++ b/app/jobs/claim_verifier_job.rb @@ -1,12 +1,14 @@ class ClaimVerifierJob < ApplicationJob def perform(claim) - AutomatedChecks::ClaimVerifier.new( - claim:, - dqt_teacher_status: claim.has_dqt_record? ? Dqt::Teacher.new(claim.dqt_teacher_status) : Dqt::Client.new.teacher.find( - claim.eligibility.teacher_reference_number, - birthdate: claim.date_of_birth.to_s, - nino: claim.national_insurance_number - ) - ).perform + if claim.eligibility.respond_to?(:teacher_reference_number) + AutomatedChecks::ClaimVerifier.new( + claim:, + dqt_teacher_status: claim.has_dqt_record? ? Dqt::Teacher.new(claim.dqt_teacher_status) : Dqt::Client.new.teacher.find( + claim.eligibility.teacher_reference_number, + birthdate: claim.date_of_birth.to_s, + nino: claim.national_insurance_number + ) + ).perform + end end end diff --git a/app/models/journeys/early_years_payment/practitioner/answers_presenter.rb b/app/models/journeys/early_years_payment/practitioner/answers_presenter.rb new file mode 100644 index 0000000000..2038282f04 --- /dev/null +++ b/app/models/journeys/early_years_payment/practitioner/answers_presenter.rb @@ -0,0 +1,30 @@ +module Journeys + module EarlyYearsPayment + module Practitioner + class AnswersPresenter < BaseAnswersPresenter + include ActionView::Helpers::TranslationHelper + + def identity_answers + [].tap do |a| + a << ["Full name", answers.full_name, "personal-details"] + a << ["Date of birth", date_of_birth_string, "personal-details"] + a << ["National Insurance number", answers.national_insurance_number, "personal-details"] + a << ["Home address", answers.address, "enter-home-address"] + a << ["Preferred email address", answers.email_address, "email-address"] + a << ["Provide mobile number?", answers.provide_mobile_number? ? "Yes" : "No", "provide-mobile-number"] + a << ["Preferred mobile number", answers.mobile_number, "mobile-number"] if answers.provide_mobile_number? + end + end + + def payment_answers + [].tap do |a| + a << ["Name on the account", answers.banking_name, "personal-bank-account"] + a << ["Sort code", answers.bank_sort_code, "personal-bank-account"] + a << ["Account number", answers.bank_account_number, "personal-bank-account"] + a << ["Payroll gender", answers.payroll_gender, "gender"] + end + end + end + end + end +end diff --git a/app/models/policies/early_years_payments/eligibility.rb b/app/models/policies/early_years_payments/eligibility.rb index b8382d591c..9629cf1a75 100644 --- a/app/models/policies/early_years_payments/eligibility.rb +++ b/app/models/policies/early_years_payments/eligibility.rb @@ -17,8 +17,8 @@ def eligible_ey_provider EligibleEyProvider.find_by_urn(nursery_urn) end - def practitioner_claim_submitted? - practitioner_claim_submitted_at.present? + def provider_claim_submitted? + provider_claim_submitted_at.present? end end end diff --git a/app/views/early_years_payment/practitioner/claims/check_your_answers.html.erb b/app/views/early_years_payment/practitioner/claims/check_your_answers.html.erb index 48cdce8528..f187407cb5 100644 --- a/app/views/early_years_payment/practitioner/claims/check_your_answers.html.erb +++ b/app/views/early_years_payment/practitioner/claims/check_your_answers.html.erb @@ -1 +1,29 @@ -placeholder +<% content_for( + :page_title, + page_title( + t("early_years_payment_practitioner.check_your_answers.title"), + journey: current_journey_routing_name, + show_error: @form.errors.any? + ) +) %> + +
+
+ <%# Errors are from the SubmissionsController %> + <% if @form.errors.any? %> + <%= render("shared/error_summary", instance: @form) %> + <% end %> + +

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

+ + <%= render partial: "claims/check_your_answers_section", locals: {heading: "Personal details", answers: journey.answers_for_claim(@form.journey_session).identity_answers} %> + + <%= render partial: "claims/check_your_answers_section", locals: {heading: "Bank account information", answers: journey.answers_for_claim(@form.journey_session).payment_answers} %> + + <%= form_with url: claim_submission_path, builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> + <%= f.govuk_submit t("early_years_payment_practitioner.check_your_answers.btn_text") %> + <% end %> +
+
diff --git a/app/views/early_years_payment/practitioner/submissions/show.html.erb b/app/views/early_years_payment/practitioner/submissions/show.html.erb new file mode 100644 index 0000000000..48cdce8528 --- /dev/null +++ b/app/views/early_years_payment/practitioner/submissions/show.html.erb @@ -0,0 +1 @@ +placeholder diff --git a/config/analytics.yml b/config/analytics.yml index 0783c7d559..ca63ca8517 100644 --- a/config/analytics.yml +++ b/config/analytics.yml @@ -318,4 +318,5 @@ shared: - returning_within_6_months - created_at - updated_at - - practitioner_claim_submitted_at + - provider_claim_submitted_at + - practitioner_claim_started_at diff --git a/config/locales/en.yml b/config/locales/en.yml index 6959e7d1c0..10ad1b07c7 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1431,6 +1431,9 @@ en: label: Your email address hint1: We’ll use this to update you with progress on your claim. hint2: We recommend you use a non-work email address in case your circumstances change while we process your claim. + check_your_answers: + title: Check your answers before submitting this claim + btn_text: Accept and send activerecord: errors: models: diff --git a/db/migrate/20241017113701_add_provider_claim_submitted_at_to_early_years_payment_eligibilities.rb b/db/migrate/20241017113701_add_provider_claim_submitted_at_to_early_years_payment_eligibilities.rb new file mode 100644 index 0000000000..06af20b8a7 --- /dev/null +++ b/db/migrate/20241017113701_add_provider_claim_submitted_at_to_early_years_payment_eligibilities.rb @@ -0,0 +1,7 @@ +class AddProviderClaimSubmittedAtToEarlyYearsPaymentEligibilities < ActiveRecord::Migration[7.0] + def change + add_column :early_years_payment_eligibilities, :provider_claim_submitted_at, :datetime + add_column :early_years_payment_eligibilities, :practitioner_claim_started_at, :datetime + remove_column :early_years_payment_eligibilities, :practitioner_claim_submitted_at, :datetime + end +end diff --git a/db/schema.rb b/db/schema.rb index cc19519bba..fd7e4e3b8c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2024_10_15_121145) do +ActiveRecord::Schema[7.0].define(version: 2024_10_17_113701) do # These are extensions that must be enabled in order to support this database enable_extension "citext" enable_extension "pg_trgm" @@ -197,7 +197,8 @@ t.date "start_date" t.boolean "child_facing_confirmation_given" t.boolean "returning_within_6_months" - t.datetime "practitioner_claim_submitted_at" + t.datetime "provider_claim_submitted_at" + t.datetime "practitioner_claim_started_at" end create_table "eligible_ey_providers", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| diff --git a/spec/factories/claims.rb b/spec/factories/claims.rb index 22677ff79c..ad6b25c8bf 100644 --- a/spec/factories/claims.rb +++ b/spec/factories/claims.rb @@ -106,6 +106,10 @@ reference { Reference.new.to_s } end + trait :early_years_provider_submitted do + reference { Reference.new.to_s } + end + trait :policy_options_provided_with_both do policy_options_provided { [ diff --git a/spec/factories/early_years_payments/eligibilities.rb b/spec/factories/early_years_payments/eligibilities.rb index f4ff4eed0a..9eb8be6d69 100644 --- a/spec/factories/early_years_payments/eligibilities.rb +++ b/spec/factories/early_years_payments/eligibilities.rb @@ -1,7 +1,7 @@ FactoryBot.define do factory :early_years_payments_eligibility, class: "Policies::EarlyYearsPayments::Eligibility" do - trait :practitioner_claim_submitted do - practitioner_claim_submitted_at { Time.zone.now } + trait :provider_claim_submitted do + provider_claim_submitted_at { Time.zone.now } end end end diff --git a/spec/factories/journeys/early_years_payment/practitioner/answers.rb b/spec/factories/journeys/early_years_payment/practitioner/answers.rb new file mode 100644 index 0000000000..44788ac043 --- /dev/null +++ b/spec/factories/journeys/early_years_payment/practitioner/answers.rb @@ -0,0 +1,21 @@ +FactoryBot.define do + factory :early_years_payment_practitioner_answers, class: "Journeys::EarlyYearsPayment::Practitioner::SessionAnswers" do + trait :eligible do + academic_year { AcademicYear.current } + email_address { "practitioner@example.com" } + email_verified { true } + first_name { "John" } + surname { "Doe" } + provide_mobile_number { false } + national_insurance_number { generate(:national_insurance_number) } + date_of_birth { 20.years.ago.to_date } + banking_name { "John Doe" } + bank_sort_code { rand(100000..999999) } + bank_account_number { rand(10000000..99999999) } + end + + trait :submittable do + eligible + end + end +end diff --git a/spec/features/early_years_payment/practitioner/find_reference_spec.rb b/spec/features/early_years_payment/practitioner/find_reference_spec.rb index 06e6d8e277..99af7c0ae9 100644 --- a/spec/features/early_years_payment/practitioner/find_reference_spec.rb +++ b/spec/features/early_years_payment/practitioner/find_reference_spec.rb @@ -6,8 +6,7 @@ :claim, policy: Policies::EarlyYearsPayments, reference: "foo", - practitioner_email_address: "user@example.com", - submitted_at: Time.zone.now + practitioner_email_address: "user@example.com" ) end @@ -68,7 +67,7 @@ :claim, :submitted, policy: Policies::EarlyYearsPayments, - eligibility: build(:early_years_payments_eligibility, :practitioner_claim_submitted, nursery_urn: eligible_ey_provider.urn), + eligibility: build(:early_years_payments_eligibility, nursery_urn: eligible_ey_provider.urn), reference: "foo", practitioner_email_address: "user@example.com" ) diff --git a/spec/features/early_years_payment/practitioner/happy_path_spec.rb b/spec/features/early_years_payment/practitioner/happy_path_spec.rb index bee031bbfb..12f949be44 100644 --- a/spec/features/early_years_payment/practitioner/happy_path_spec.rb +++ b/spec/features/early_years_payment/practitioner/happy_path_spec.rb @@ -71,6 +71,19 @@ expect(page).to have_text(I18n.t("forms.gender.questions.payroll_gender")) choose "Female" - # click_on "Continue" + click_on "Continue" + + expect(page).to have_content("Check your answers before submitting this claim") + expect do + perform_enqueued_jobs { click_on "Accept and send" } + end.to not_change { Claim.count } + .and not_change { Policies::EarlyYearsPayments::Eligibility.count } + .and not_change { claim.reload.reference } + + expect(claim.eligibility.practitioner_claim_started_at).to be_present + expect(claim.reload.submitted_at).to be_present + + # check answers were saved on the claim + expect(claim.reload.national_insurance_number).to eq "PX321499A" 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 afb0ee1693..501321a34c 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 @@ -82,6 +82,8 @@ claim = Claim.last expect(claim.provider_contact_name).to eq "John Doe" expect(page).to have_content(claim.reference) + expect(claim.submitted_at).to be_nil + expect(claim.eligibility.reload.provider_claim_submitted_at).to be_present end scenario "using magic link after having completed some of the journey" do diff --git a/spec/forms/journeys/early_years_payment/practitioner/claim_submission_form_spec.rb b/spec/forms/journeys/early_years_payment/practitioner/claim_submission_form_spec.rb new file mode 100644 index 0000000000..aac21f5213 --- /dev/null +++ b/spec/forms/journeys/early_years_payment/practitioner/claim_submission_form_spec.rb @@ -0,0 +1,42 @@ +require "rails_helper" + +RSpec.describe Journeys::EarlyYearsPayment::Practitioner::ClaimSubmissionForm do + before do + create(:journey_configuration, :early_years_payment_practitioner) + end + + let(:journey) { Journeys::EarlyYearsPayment::Practitioner } + + let(:journey_session) { create(:early_years_payment_practitioner_session, answers: answers) } + let(:form) { described_class.new(journey_session: journey_session) } + let!(:existing_claim) { create(:claim, :early_years_provider_submitted, policy: Policies::EarlyYearsPayments) } + + describe "#save" do + subject { form.save } + + let(:claim) { form.claim } + let(:eligibility) { claim.eligibility } + let(:answers) { build(:early_years_payment_practitioner_answers, :submittable, reference_number: existing_claim.reference) } + + it { is_expected.to be_truthy } + + it "saves some answers into the Claim model" do + subject + 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.national_insurance_number).to eq answers.national_insurance_number + expect(claim.date_of_birth).to eq answers.date_of_birth + expect(claim.banking_name).to eq answers.banking_name + expect(claim.bank_sort_code).to eq answers.bank_sort_code + expect(claim.payroll_gender).to eq answers.payroll_gender + expect(claim.email_address).to eq answers.email_address + end + + it "saves some answers into the Eligibility model" do + subject + expect(eligibility.practitioner_claim_started_at).to be_present + end + end +end diff --git a/spec/forms/journeys/early_years_payment/practitioner/find_reference_form_spec.rb b/spec/forms/journeys/early_years_payment/practitioner/find_reference_form_spec.rb index e8eab13f00..86d0be3040 100644 --- a/spec/forms/journeys/early_years_payment/practitioner/find_reference_form_spec.rb +++ b/spec/forms/journeys/early_years_payment/practitioner/find_reference_form_spec.rb @@ -77,9 +77,8 @@ let(:claim) do create( :claim, - :submitted, policy: Policies::EarlyYearsPayments, - eligibility: build(:early_years_payments_eligibility, nursery_urn: eligible_ey_provider.urn), + eligibility: build(:early_years_payments_eligibility, :provider_claim_submitted, nursery_urn: eligible_ey_provider.urn), reference: "foo" ) end @@ -97,7 +96,7 @@ :claim, :submitted, policy: Policies::EarlyYearsPayments, - eligibility: build(:early_years_payments_eligibility, :practitioner_claim_submitted, nursery_urn: eligible_ey_provider.urn), + eligibility: build(:early_years_payments_eligibility, nursery_urn: eligible_ey_provider.urn), reference: "foo" ) 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 index 9fed2e5aab..57acc116f6 100644 --- 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 @@ -22,7 +22,7 @@ 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.submitted_at).to be_nil 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 @@ -37,6 +37,7 @@ expect(eligibility.child_facing_confirmation_given).to eq answers.child_facing_confirmation_given expect(eligibility.returning_within_6_months).to eq answers.returning_within_6_months expect(eligibility.start_date).to eq answers.start_date + expect(eligibility.provider_claim_submitted_at).to be_present end it "sends a notify email to the practitioner" do diff --git a/spec/jobs/claim_verifier_job_spec.rb b/spec/jobs/claim_verifier_job_spec.rb index 46163c322a..83f6bab5d1 100644 --- a/spec/jobs/claim_verifier_job_spec.rb +++ b/spec/jobs/claim_verifier_job_spec.rb @@ -38,6 +38,15 @@ expect(AutomatedChecks::ClaimVerifier).to receive(:new).with(claim:, dqt_teacher_status: mock_payload) described_class.new.perform(claim) end + + context "when the claim does not have a TRN" do + let(:claim) { build(:claim, policy: Policies::EarlyYearsPayments) } + + it "does not perform the verifier job" do + expect(AutomatedChecks::ClaimVerifier).not_to receive(:new) + described_class.new.perform(claim) + end + end end context "when the claim does not have a DQT record payload" do diff --git a/spec/models/journeys/early_years_payment/practitioner/answers_presenter_spec.rb b/spec/models/journeys/early_years_payment/practitioner/answers_presenter_spec.rb new file mode 100644 index 0000000000..be293f04f2 --- /dev/null +++ b/spec/models/journeys/early_years_payment/practitioner/answers_presenter_spec.rb @@ -0,0 +1,75 @@ +require "rails_helper" + +RSpec.describe Journeys::EarlyYearsPayment::Practitioner::AnswersPresenter do + let(:journey) { Journeys::EarlyYearsPayment } + let(:journey_session) { create(:early_years_payment_practitioner_session, answers:) } + let(:answers) { + build( + :early_years_payment_practitioner_answers, + first_name: "John", + surname: "Doe", + date_of_birth: Date.new(1970, 1, 1), + national_insurance_number: "QQ123456C", + address_line_1: "1", + address_line_2: "Some Street", + address_line_3: "Some City", + postcode: "AB1 C23", + email_address: "practitioner@example.com", + provide_mobile_number: true, + mobile_number: "07700900001", + banking_name: "Mr John Doe", + bank_account_number: "12345678", + bank_sort_code: "123456", + payroll_gender: "male" + ) + } + + describe "#identity_answers" do + subject { described_class.new(journey_session).identity_answers } + + context "Full name" do + it { is_expected.to include(["Full name", "John Doe", "personal-details"]) } + end + + context "Date of birth" do + it { is_expected.to include(["Date of birth", "1 January 1970", "personal-details"]) } + end + + context "National Insurance number" do + it { is_expected.to include(["National Insurance number", "QQ123456C", "personal-details"]) } + end + + context "Home address" do + it { is_expected.to include(["Home address", "1, Some Street, Some City, AB1 C23", "enter-home-address"]) } + end + + context "Email address" do + it { is_expected.to include(["Preferred email address", "practitioner@example.com", "email-address"]) } + end + + context "Mobile number" do + it { is_expected.to include(["Provide mobile number?", "Yes", "provide-mobile-number"]) } + it { is_expected.to include(["Preferred mobile number", "07700900001", "mobile-number"]) } + end + end + + describe "#payment_answers" do + subject { described_class.new(journey_session).payment_answers } + + context "Bank account name" do + it { is_expected.to include(["Name on the account", "Mr John Doe", "personal-bank-account"]) } + end + + context "Sort code" do + it { is_expected.to include(["Sort code", "123456", "personal-bank-account"]) } + end + + context "Account number" do + it { is_expected.to include(["Account number", "12345678", "personal-bank-account"]) } + end + + context "Payroll gender" do + it { is_expected.to include(["Payroll gender", "male", "gender"]) } + end + end +end