From 0630b80bc0b24cc7e477ca5529e94d49ff7d7eec Mon Sep 17 00:00:00 2001 From: Richard Lynch Date: Wed, 19 Jun 2024 21:03:10 +0100 Subject: [PATCH] Handle ineligible option If the teacher picks other they are ineligible so send them to the ineligiblity screen. Thankfully the existing IRP shows a static message so we don't have to deal with showing them the ineligibility reason. --- .../slug_sequence.rb | 3 +- .../policy_eligibility_checker.rb | 15 ++++- .../claims/ineligible.html.erb | 28 ++++++++++ ...eligible_route_completing_the_form_spec.rb | 25 +++++++++ .../policy_eligibility_checker_spec.rb | 56 +++++++++++++++++++ 5 files changed, 125 insertions(+), 2 deletions(-) create mode 100644 app/views/get_a_teacher_relocation_payment/claims/ineligible.html.erb create mode 100644 spec/features/get_a_teacher_relocation_payment/ineligible_route_completing_the_form_spec.rb create mode 100644 spec/models/policies/international_relocation_payments/policy_eligibility_checker_spec.rb diff --git a/app/models/journeys/get_a_teacher_relocation_payment/slug_sequence.rb b/app/models/journeys/get_a_teacher_relocation_payment/slug_sequence.rb index ab74fcdcb7..3847df2489 100644 --- a/app/models/journeys/get_a_teacher_relocation_payment/slug_sequence.rb +++ b/app/models/journeys/get_a_teacher_relocation_payment/slug_sequence.rb @@ -7,7 +7,8 @@ class SlugSequence ] RESULTS_SLUGS = [ - "check-your-answers" + "check-your-answers", + "ineligible" ].freeze SLUGS = ELIGIBILITY_SLUGS + RESULTS_SLUGS diff --git a/app/models/policies/international_relocation_payments/policy_eligibility_checker.rb b/app/models/policies/international_relocation_payments/policy_eligibility_checker.rb index 63c33ff7b1..22dcc84aff 100644 --- a/app/models/policies/international_relocation_payments/policy_eligibility_checker.rb +++ b/app/models/policies/international_relocation_payments/policy_eligibility_checker.rb @@ -10,11 +10,24 @@ def initialize(answers:) end def status + return :ineligible if ineligible? + :eligible_now end def ineligible? - false + ineligible_reason.present? + end + + private + + def ineligible_reason + case answers.attributes.symbolize_keys + in application_route: "other" + "application route other not accecpted" + else + nil + end end end end diff --git a/app/views/get_a_teacher_relocation_payment/claims/ineligible.html.erb b/app/views/get_a_teacher_relocation_payment/claims/ineligible.html.erb new file mode 100644 index 0000000000..dfd25e6eef --- /dev/null +++ b/app/views/get_a_teacher_relocation_payment/claims/ineligible.html.erb @@ -0,0 +1,28 @@ +
+
+

+ We’re sorry, but you are not currently eligible + for the international relocation payment +

+
+
+ +
+
+

+ <%= govuk_link_to( + "Check full eligibility details for teachers.", + "https://getintoteaching.education.gov.uk/non-uk-teachers/get-an-international-relocation-payment/#criteria-for-teachers", + target: "_blank" + ) %> +

+ +

+ <%= govuk_link_to( + "Check full eligibility details for trainees.", + "https://getintoteaching.education.gov.uk/non-uk-teachers/get-an-international-relocation-payment/#criteria-for-trainee-teachers", + target: "_blank" + ) %> +

+
+
diff --git a/spec/features/get_a_teacher_relocation_payment/ineligible_route_completing_the_form_spec.rb b/spec/features/get_a_teacher_relocation_payment/ineligible_route_completing_the_form_spec.rb new file mode 100644 index 0000000000..25f5490794 --- /dev/null +++ b/spec/features/get_a_teacher_relocation_payment/ineligible_route_completing_the_form_spec.rb @@ -0,0 +1,25 @@ +require "rails_helper" + +describe "ineligible route: completing the form" do + include GetATeacherRelocationPayment::StepHelpers + + before do + create(:journey_configuration, :get_a_teacher_relocation_payment) + end + + describe "navigating forward" do + context "ineligible application route" do + it "shows the ineligible page" do + when_i_start_the_form + and_i_complete_application_route_question_with(option: "Other") + then_i_see_the_ineligible_page + end + end + end + + def then_i_see_the_ineligible_page + expect(page).to have_content( + "We’re sorry, but you are not currently eligible for the international relocation payment" + ) + end +end diff --git a/spec/models/policies/international_relocation_payments/policy_eligibility_checker_spec.rb b/spec/models/policies/international_relocation_payments/policy_eligibility_checker_spec.rb new file mode 100644 index 0000000000..c12c675f3d --- /dev/null +++ b/spec/models/policies/international_relocation_payments/policy_eligibility_checker_spec.rb @@ -0,0 +1,56 @@ +require "rails_helper" + +describe Policies::InternationalRelocationPayments::PolicyEligibilityChecker do + let(:answers) do + build( + :get_a_teacher_relocation_payment_answers, + application_route: application_route + ) + end + + let(:checker) { described_class.new(answers: answers) } + + describe "#status" do + subject { checker.status } + + context "when the application route is 'other'" do + let(:application_route) { "other" } + + it { is_expected.to eq(:ineligible) } + end + + context "when the application route is 'teacher'" do + let(:application_route) { "teacher" } + + it { is_expected.to eq(:eligible_now) } + end + + context "when the application route is 'salaried_trainee'" do + let(:application_route) { "salaried_trainee" } + + it { is_expected.to eq(:eligible_now) } + end + end + + describe "#ineligible?" do + subject { checker.ineligible? } + + context "when the application route is 'other'" do + let(:application_route) { "other" } + + it { is_expected.to eq(true) } + end + + context "when the application route is 'teacher'" do + let(:application_route) { "teacher" } + + it { is_expected.to eq(false) } + end + + context "when the application route is 'salaried_trainee'" do + let(:application_route) { "salaried_trainee" } + + it { is_expected.to eq(false) } + end + end +end