diff --git a/app/models/policies/international_relocation_payments/eligibility_admin_answers_presenter.rb b/app/models/policies/international_relocation_payments/eligibility_admin_answers_presenter.rb index 977e4f6652..28bf1f8ee5 100644 --- a/app/models/policies/international_relocation_payments/eligibility_admin_answers_presenter.rb +++ b/app/models/policies/international_relocation_payments/eligibility_admin_answers_presenter.rb @@ -11,18 +11,80 @@ def initialize(eligibility) def answers [].tap do |a| + a << nationality + a << passport_number a << current_school + a << subject + a << school_headteacher_name + a << start_date + a << visa_type + a << date_of_entry end end private + def nationality + [ + admin_display_name("nationality"), + eligibility.nationality + ] + end + + def passport_number + [ + admin_display_name("passport_number"), + eligibility.passport_number + ] + end + def current_school [ translate("admin.current_school"), display_school(eligibility.current_school) ] end + + def subject + [ + admin_display_name("subject"), + eligibility.subject.capitalize + ] + end + + def school_headteacher_name + [ + admin_display_name("school_headteacher_name"), + eligibility.school_headteacher_name + ] + end + + def start_date + [ + admin_display_name("start_date"), + eligibility.start_date.strftime("%-d %B %Y") + ] + end + + def visa_type + [ + admin_display_name("visa_type"), + eligibility.visa_type + ] + end + + def date_of_entry + [ + admin_display_name("date_of_entry"), + eligibility.date_of_entry.strftime("%-d %B %Y") + ] + end + + def admin_display_name(attr) + translate( + "international_relocation_payments.admin.eligibility_answers.#{attr}" + ) + end end end end diff --git a/config/locales/en.yml b/config/locales/en.yml index db4d0493e8..66cc32681a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -786,6 +786,14 @@ en: policy_short_name: "International Relocation Payments" policy_acronym: "IRP" admin: + eligibility_answers: + nationality: "Nationality" + passport_number: "Passport number" + subject: "Subject" + school_headteacher_name: "School headteacher name" + start_date: "Contract start date" + visa_type: "Visa type" + date_of_entry: "Date of entry" task_questions: identity_confirmation: title: "Did %{claim_full_name} submit the claim?" diff --git a/spec/factories/policies/international_relocation_payments/eligibilities.rb b/spec/factories/policies/international_relocation_payments/eligibilities.rb index 6fc74a34e6..456088ce52 100644 --- a/spec/factories/policies/international_relocation_payments/eligibilities.rb +++ b/spec/factories/policies/international_relocation_payments/eligibilities.rb @@ -11,6 +11,7 @@ eligible_home_office eligible_school eligible_subject + eligible_start_date end trait :eligible_school do diff --git a/spec/models/policies/international_relocation_payments/eligibility_admin_answers_presenter_spec.rb b/spec/models/policies/international_relocation_payments/eligibility_admin_answers_presenter_spec.rb index 7dba901327..291234d846 100644 --- a/spec/models/policies/international_relocation_payments/eligibility_admin_answers_presenter_spec.rb +++ b/spec/models/policies/international_relocation_payments/eligibility_admin_answers_presenter_spec.rb @@ -1,13 +1,60 @@ require "rails_helper" RSpec.describe Policies::InternationalRelocationPayments::EligibilityAdminAnswersPresenter, type: :model do - let(:claim) { build(:claim, :submittable, policy: Policies::InternationalRelocationPayments, academic_year: "2021/2022") } + describe "#answers" do + subject { described_class.new(eligibility).answers } - subject(:presenter) { described_class.new(claim.eligibility) } + let(:school) { create(:school) } - describe "#answers" do - it "returns an array of questions and answers for displaying to service operator" do - expect(presenter.answers).to eq [[I18n.t("admin.current_school"), presenter.display_school(claim.eligibility.current_school)]] + let(:eligibility) do + build( + :international_relocation_payments_eligibility, + nationality: "American", + passport_number: "123456789", + current_school: school, + subject: "physics", + school_headteacher_name: "Principal Skinner", + start_date: Date.new(2024, 3, 1), + visa_type: "British National (Overseas) visa", + date_of_entry: Date.new(2024, 2, 1) + ) + end + + it do + is_expected.to include( + [ + "Nationality", + "American" + ], + [ + "Passport number", + "123456789" + ], + [ + "Current school", + /#{school.name}/ + ], + [ + "Subject", + "Physics" + ], + [ + "School headteacher name", + "Principal Skinner" + ], + [ + "Contract start date", + "1 March 2024" + ], + [ + "Visa type", + "British National (Overseas) visa" + ], + [ + "Date of entry", + "1 February 2024" + ] + ) end end end