From 23d0e63749924d41aa9e2857b1038473d11f84db Mon Sep 17 00:00:00 2001 From: Phil Lee Date: Mon, 12 Aug 2024 16:35:24 +0100 Subject: [PATCH] persist TRN on eligibility for FE journey --- .../claim_submission_form.rb | 4 +++- config/analytics_blocklist.yml | 2 ++ .../20240812123209_add_trn_to_fe_eligibilities.rb | 5 +++++ db/schema.rb | 3 ++- .../further_education_payments/happy_path_spec.rb | 15 ++++++++++++++- 5 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20240812123209_add_trn_to_fe_eligibilities.rb 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 8d94853e13..f3179f0459 100644 --- a/app/forms/journeys/further_education_payments/claim_submission_form.rb +++ b/app/forms/journeys/further_education_payments/claim_submission_form.rb @@ -4,7 +4,9 @@ class ClaimSubmissionForm < ::ClaimSubmissionBaseForm private def main_eligibility - @main_eligibility ||= Policies::FurtherEducationPayments::Eligibility.new + @main_eligibility ||= Policies::FurtherEducationPayments::Eligibility.new( + teacher_reference_number: @journey_session.answers.teacher_reference_number + ) end def calculate_award_amount(eligibility) diff --git a/config/analytics_blocklist.yml b/config/analytics_blocklist.yml index 0fbca5150c..88bb454fcf 100644 --- a/config/analytics_blocklist.yml +++ b/config/analytics_blocklist.yml @@ -115,5 +115,7 @@ - teacher_reference_number :student_loans_eligibilities: - teacher_reference_number + :further_education_payments_eligibilities: + - teacher_reference_number :journeys_sessions: - answers diff --git a/db/migrate/20240812123209_add_trn_to_fe_eligibilities.rb b/db/migrate/20240812123209_add_trn_to_fe_eligibilities.rb new file mode 100644 index 0000000000..2bfe005d8c --- /dev/null +++ b/db/migrate/20240812123209_add_trn_to_fe_eligibilities.rb @@ -0,0 +1,5 @@ +class AddTrnToFeEligibilities < ActiveRecord::Migration[7.0] + def change + add_column :further_education_payments_eligibilities, :teacher_reference_number, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index 37cfa208ad..b5eac09e53 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_08_08_153424) do +ActiveRecord::Schema[7.0].define(version: 2024_08_12_123209) do # These are extensions that must be enabled in order to support this database enable_extension "citext" enable_extension "pg_trgm" @@ -217,6 +217,7 @@ t.datetime "created_at", null: false t.datetime "updated_at", null: false t.decimal "award_amount", precision: 7, scale: 2 + t.text "teacher_reference_number" end create_table "international_relocation_payments_eligibilities", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| diff --git a/spec/features/further_education_payments/happy_path_spec.rb b/spec/features/further_education_payments/happy_path_spec.rb index 51bef8fd10..f5bd984d40 100644 --- a/spec/features/further_education_payments/happy_path_spec.rb +++ b/spec/features/further_education_payments/happy_path_spec.rb @@ -172,7 +172,20 @@ click_on "Continue" expect(page).to have_content("Check your answers before sending your application") - click_on "Accept and send" + + expect do + click_on "Accept and send" + end.to change { Claim.count }.by(1) + .and change { Policies::FurtherEducationPayments::Eligibility.count }.by(1) + + claim = Claim.last + + expect(claim.first_name).to eql("John") + expect(claim.surname).to eql("Doe") + + eligibility = Policies::FurtherEducationPayments::Eligibility.last + + expect(eligibility.teacher_reference_number).to eql("1234567") expect(page).to have_content("You applied for a further education retention payment") end