Skip to content

Commit

Permalink
Additional eligibility answers
Browse files Browse the repository at this point in the history
Updates the admin eligibility presenter to include the rest of the
eligibility details
  • Loading branch information
rjlynch committed Jul 8, 2024
1 parent e6f4f71 commit 413a759
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 8 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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?"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
eligible_home_office
eligible_school
eligible_subject
eligible_start_date
end

trait :eligible_school do
Expand Down
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 413a759

Please sign in to comment.