diff --git a/app/views/admin/tasks/_claim_summary.html.erb b/app/views/admin/tasks/_claim_summary.html.erb
index 9da8f08daf..6197d0c2b5 100644
--- a/app/views/admin/tasks/_claim_summary.html.erb
+++ b/app/views/admin/tasks/_claim_summary.html.erb
@@ -26,7 +26,7 @@
- <%= claim.teacher_reference_number %>
+ <%= claim.eligibility.teacher_reference_number %>
diff --git a/config/analytics_blocklist.yml b/config/analytics_blocklist.yml
index f50bb151b0..e353302397 100644
--- a/config/analytics_blocklist.yml
+++ b/config/analytics_blocklist.yml
@@ -19,7 +19,7 @@
- building_society_roll_number
- banking_name
- mobile_number
- - teacher_reference_number
+ - column_to_remove_teacher_reference_number
- email_address
- payroll_gender
- one_time_password
@@ -98,4 +98,9 @@
- gender_digit
:international_relocation_payments_eligibilities:
- passport_number
-
+ :levelling_up_premium_payments_eligibilities:
+ - teacher_reference_number
+ :early_career_payments_eligibilities:
+ - teacher_reference_number
+ :student_loans_eligibilities:
+ - teacher_reference_number
diff --git a/config/brakeman.ignore b/config/brakeman.ignore
index 4bf570841b..1e49f435ac 100644
--- a/config/brakeman.ignore
+++ b/config/brakeman.ignore
@@ -30,7 +30,7 @@
"check_name": "SQL",
"message": "Possible SQL injection",
"file": "app/models/claim/search.rb",
- "line": 28,
+ "line": 45,
"link": "https://brakemanscanner.org/docs/warning_types/sql_injection/",
"code": "Claim.submitted.where(\"LOWER(#{attribute}) = LOWER(?)\", search_term)",
"render_path": null,
@@ -118,13 +118,13 @@
{
"warning_type": "SQL Injection",
"warning_code": 0,
- "fingerprint": "aac74520956533997d73d1c601c2bcde5d3cd501f14401fb9cb8e2bfdc7862fa",
+ "fingerprint": "f83635b54e1ce0088178d8082ffe632ab8aa81b10fce1026caf87f286cb4d81a",
"check_name": "SQL",
"message": "Possible SQL injection",
"file": "app/models/claim/matching_attribute_finder.rb",
- "line": 31,
+ "line": 54,
"link": "https://brakemanscanner.org/docs/warning_types/sql_injection/",
- "code": "Claim.where(\"LOWER(#{\"CONCAT(#{attributes.join(\",\")})\"}) = LOWER(?)\", values_for_attributes(attributes).join)",
+ "code": "Claim.where(\"LOWER(#{\"CONCAT(#{attributes.join(\",\")})\"}) = LOWER(?)\", values_for_attributes(source_claim, attributes).join)",
"render_path": null,
"location": {
"type": "method",
@@ -136,55 +136,9 @@
"cwe_id": [
89
],
- "note": "The concetenated attributes in the CONCAT operation are not user-generated, so this can be safely ignored"
- },
- {
- "warning_type": "Redirect",
- "warning_code": 18,
- "fingerprint": "b838db1b7beff28cdeff71a154a46d7c57062fb11aebf82f0487a9991445bea5",
- "check_name": "Redirect",
- "message": "Possible unprotected redirect",
- "file": "app/controllers/concerns/part_of_claim_journey.rb",
- "line": 25,
- "link": "https://brakemanscanner.org/docs/warning_types/redirect/",
- "code": "redirect_to(Journeys::Configuration.start_page_url(current_journey_routing_name), :allow_other_host => true)",
- "render_path": null,
- "location": {
- "type": "method",
- "class": "PartOfClaimJourney",
- "method": "send_unstarted_claimants_to_the_start"
- },
- "user_input": "Journeys::Configuration.start_page_url(current_journey_routing_name)",
- "confidence": "Weak",
- "cwe_id": [
- 601
- ],
- "note": ""
- },
- {
- "warning_type": "Redirect",
- "warning_code": 18,
- "fingerprint": "d7efbb65a649f824e34aa86f2d844a9d5ffac945eea04198f59418ac1998721c",
- "check_name": "Redirect",
- "message": "Possible unprotected redirect",
- "file": "app/controllers/submissions_controller.rb",
- "line": 22,
- "link": "https://brakemanscanner.org/docs/warning_types/redirect/",
- "code": "redirect_to(Journeys::Configuration.start_page_url(current_journey_routing_name), :allow_other_host => true)",
- "render_path": null,
- "location": {
- "type": "method",
- "class": "SubmissionsController",
- "method": "show"
- },
- "user_input": "Journeys::Configuration.start_page_url(current_journey_routing_name)",
- "confidence": "Weak",
- "cwe_id": [
- 601
- ],
"note": ""
}
],
- "updated": "2024-03-07 12:34:07 +0000",
+ "updated": "2024-06-20 16:06:05 +0100",
"brakeman_version": "6.1.2"
}
diff --git a/db/migrate/20240511100914_move_teacher_reference_number_to_eligibility.rb b/db/migrate/20240511100914_move_teacher_reference_number_to_eligibility.rb
new file mode 100644
index 0000000000..557ac81636
--- /dev/null
+++ b/db/migrate/20240511100914_move_teacher_reference_number_to_eligibility.rb
@@ -0,0 +1,19 @@
+class MoveTeacherReferenceNumberToEligibility < ActiveRecord::Migration[7.0]
+ def change
+ add_column :early_career_payments_eligibilities, :teacher_reference_number, :string, limit: 11
+ add_column :levelling_up_premium_payments_eligibilities, :teacher_reference_number, :string, limit: 11
+ add_column :student_loans_eligibilities, :teacher_reference_number, :string, limit: 11
+
+ add_index :early_career_payments_eligibilities, :teacher_reference_number, name: "index_ecp_eligibility_trn"
+ add_index :levelling_up_premium_payments_eligibilities, :teacher_reference_number, name: "index_lupp_eligibility_trn"
+ add_index :student_loans_eligibilities, :teacher_reference_number, name: "index_sl_eligibility_trn"
+
+ # Copy teacher_reference_number from Claim to Eligibility
+ Claim.all.includes(:eligibility).each do |claim|
+ claim.eligibility.update!(teacher_reference_number: claim.teacher_reference_number)
+ end
+
+ # Keep the old column but rename it so it's not accidentally used, needs removing soon after migration is successful
+ rename_column :claims, :teacher_reference_number, :column_to_remove_teacher_reference_number
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 2bbacefc1c..2db075d1f0 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -49,7 +49,7 @@
t.string "address_line_4", limit: 100
t.string "postcode", limit: 11
t.date "date_of_birth"
- t.string "teacher_reference_number", limit: 11
+ t.string "column_to_remove_teacher_reference_number", limit: 11
t.string "national_insurance_number", limit: 9
t.string "email_address", limit: 256
t.string "bank_sort_code", limit: 6
@@ -170,7 +170,9 @@
t.decimal "award_amount", precision: 7, scale: 2
t.boolean "induction_completed"
t.boolean "school_somewhere_else"
+ t.string "teacher_reference_number", limit: 11
t.index ["current_school_id"], name: "index_early_career_payments_eligibilities_on_current_school_id"
+ t.index ["teacher_reference_number"], name: "index_ecp_eligibility_trn"
end
create_table "file_uploads", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
@@ -246,7 +248,9 @@
t.boolean "eligible_degree_subject"
t.boolean "induction_completed"
t.boolean "school_somewhere_else"
+ t.string "teacher_reference_number", limit: 11
t.index ["current_school_id"], name: "index_lup_payments_eligibilities_on_current_school_id"
+ t.index ["teacher_reference_number"], name: "index_lupp_eligibility_trn"
end
create_table "local_authorities", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
@@ -406,9 +410,11 @@
t.boolean "had_leadership_position"
t.boolean "mostly_performed_leadership_duties"
t.boolean "claim_school_somewhere_else"
+ t.string "teacher_reference_number", limit: 11
t.index ["claim_school_id"], name: "index_student_loans_eligibilities_on_claim_school_id"
t.index ["created_at"], name: "index_student_loans_eligibilities_on_created_at"
t.index ["current_school_id"], name: "index_student_loans_eligibilities_on_current_school_id"
+ t.index ["teacher_reference_number"], name: "index_sl_eligibility_trn"
end
create_table "support_tickets", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
diff --git a/spec/factories/amendments.rb b/spec/factories/amendments.rb
index e1ba30273b..0abe1b5004 100644
--- a/spec/factories/amendments.rb
+++ b/spec/factories/amendments.rb
@@ -2,12 +2,12 @@
factory :amendment do
association :claim, factory: [:claim, :submitted]
association :created_by, factory: :dfe_signin_user
- claim_changes { {"teacher_reference_number" => [generate(:teacher_reference_number).to_s, claim.teacher_reference_number]} }
+ claim_changes { {"teacher_reference_number" => [generate(:teacher_reference_number).to_s, claim.eligibility.teacher_reference_number]} }
notes { "We couldn’t find the teacher in Teacher Pensions Service data. We contacted them in Zendesk and they told us they made a typo and gave their correct TRN" }
trait :personal_data_removed do
personal_data_removed_at { Time.zone.now }
- claim_changes { {"teacher_reference_number" => [generate(:teacher_reference_number).to_s, claim.teacher_reference_number], "bank_account_number" => nil} }
+ claim_changes { {"teacher_reference_number" => [generate(:teacher_reference_number).to_s, claim.eligibility.teacher_reference_number], "bank_account_number" => nil} }
end
end
end
diff --git a/spec/factories/claims.rb b/spec/factories/claims.rb
index 71ee639506..22579f1c9a 100644
--- a/spec/factories/claims.rb
+++ b/spec/factories/claims.rb
@@ -39,7 +39,6 @@
trait :with_details_from_dfe_identity do
first_name { "Jo" }
surname { "Bloggs" }
- teacher_reference_number { generate(:teacher_reference_number) }
date_of_birth { 20.years.ago.to_date }
national_insurance_number { generate(:national_insurance_number) }
end
diff --git a/spec/factories/early_career_payments/eligibilities.rb b/spec/factories/early_career_payments/eligibilities.rb
index 269b369b67..dfcccd38df 100644
--- a/spec/factories/early_career_payments/eligibilities.rb
+++ b/spec/factories/early_career_payments/eligibilities.rb
@@ -3,6 +3,7 @@
award_amount { 5000.0 }
trait :eligible do
+ teacher_reference_number { generate(:teacher_reference_number) }
eligible_now
end
diff --git a/spec/factories/levelling_up_premium_payments/eligibilities.rb b/spec/factories/levelling_up_premium_payments/eligibilities.rb
index f9e81c8a55..e387e12253 100644
--- a/spec/factories/levelling_up_premium_payments/eligibilities.rb
+++ b/spec/factories/levelling_up_premium_payments/eligibilities.rb
@@ -2,7 +2,8 @@
factory :levelling_up_premium_payments_eligibility, class: "Policies::LevellingUpPremiumPayments::Eligibility" do
award_amount { 2000.0 }
- trait :eligible do # TODO rename
+ trait :eligible do
+ teacher_reference_number { generate(:teacher_reference_number) }
eligible_now
end
diff --git a/spec/factories/payments.rb b/spec/factories/payments.rb
index e866c32dc3..991361a4d9 100644
--- a/spec/factories/payments.rb
+++ b/spec/factories/payments.rb
@@ -7,10 +7,10 @@
claims do
personal_details = {
national_insurance_number: generate(:national_insurance_number),
- teacher_reference_number: generate(:teacher_reference_number),
email_address: "email@example.com",
bank_sort_code: "220011",
- bank_account_number: "12345678"
+ bank_account_number: "12345678",
+ eligibility_attributes: {teacher_reference_number: generate(:teacher_reference_number)}
}
claim_policies.map do |policy|
association(:claim, :approved, personal_details.merge(policy: policy))
diff --git a/spec/factories/student_loans/eligibilities.rb b/spec/factories/student_loans/eligibilities.rb
index 95e5a21523..bdb969d62b 100644
--- a/spec/factories/student_loans/eligibilities.rb
+++ b/spec/factories/student_loans/eligibilities.rb
@@ -11,6 +11,7 @@
had_leadership_position { true }
mostly_performed_leadership_duties { false }
student_loan_repayment_amount { 1000 }
+ teacher_reference_number { generate(:teacher_reference_number) }
end
trait :ineligible do
diff --git a/spec/features/admin_amend_claim_spec.rb b/spec/features/admin_amend_claim_spec.rb
index 872e13534b..5323c37668 100644
--- a/spec/features/admin_amend_claim_spec.rb
+++ b/spec/features/admin_amend_claim_spec.rb
@@ -8,7 +8,7 @@
RSpec.feature "Admin amends a claim" do
let(:claim) do
create(:claim, :submitted,
- teacher_reference_number: "1234567",
+ eligibility_attributes: {teacher_reference_number: "1234567"},
payroll_gender: :dont_know,
date_of_birth: date_of_birth,
student_loan_plan: :plan_1,
@@ -57,7 +57,7 @@
expect(amendment.notes).to eq("This claimant got some of their details wrong and then contacted us")
expect(amendment.created_by).to eq(@signed_in_user)
- expect(claim.reload.teacher_reference_number).to eq("7654321")
+ expect(claim.eligibility.reload.teacher_reference_number).to eq("7654321")
expect(claim.date_of_birth).to eq(new_date_of_birth)
expect(claim.student_loan_plan).to eq("plan_2")
expect(claim.bank_sort_code).to eq("111213")
@@ -88,7 +88,7 @@
fill_in "Teacher reference number", with: "7654321"
- expect { click_on "Cancel" }.not_to change { [claim.reload.amendments.size, claim.teacher_reference_number] }
+ expect { click_on "Cancel" }.not_to change { [claim.reload.amendments.size, claim.eligibility.teacher_reference_number] }
expect(current_url).to eq(admin_claim_tasks_url(claim))
end
diff --git a/spec/features/admin_claim_tasks_update_with_dqt_api_spec.rb b/spec/features/admin_claim_tasks_update_with_dqt_api_spec.rb
index c06d689435..77639b8b7f 100644
--- a/spec/features/admin_claim_tasks_update_with_dqt_api_spec.rb
+++ b/spec/features/admin_claim_tasks_update_with_dqt_api_spec.rb
@@ -110,7 +110,7 @@ def task_outcome
status = 200
end
- stub_request(:get, "#{ENV["DQT_API_URL"]}teachers/#{claim.teacher_reference_number}")
+ stub_request(:get, "#{ENV["DQT_API_URL"]}teachers/#{claim.eligibility.teacher_reference_number}")
.with(query: WebMock::API.hash_including({
birthdate: claim.date_of_birth.to_s,
nino: claim.national_insurance_number
@@ -173,7 +173,7 @@ def task_outcome
date_of_birth: claim.date_of_birth,
name: "#{claim.first_name} #{claim.surname}",
national_insurance_number: claim.national_insurance_number,
- teacher_reference_number: claim.teacher_reference_number
+ teacher_reference_number: claim.eligibility.teacher_reference_number
}
end
@@ -211,7 +211,7 @@ def task_outcome
date_of_birth: claim.date_of_birth,
name: "#{claim.first_name} #{claim.surname}",
national_insurance_number: "QQ100000B",
- teacher_reference_number: claim.teacher_reference_number
+ teacher_reference_number: claim.eligibility.teacher_reference_number
}
end
@@ -290,7 +290,7 @@ def task_outcome
scenario "shows the notes added as part of automated identity checking" do
expect(notes).to include(
have_text("Teacher reference number not matched").and(
- have_text("Claimant: \"#{claim.teacher_reference_number}\"").and(
+ have_text("Claimant: \"#{claim.eligibility.teacher_reference_number}\"").and(
have_text("DQT: \"7654321\"").and(
have_text("by an automated check")
)
@@ -319,7 +319,7 @@ def task_outcome
date_of_birth: claim.date_of_birth,
name: "Except #{claim.surname}",
national_insurance_number: claim.national_insurance_number,
- teacher_reference_number: claim.teacher_reference_number
+ teacher_reference_number: claim.eligibility.teacher_reference_number
}
end
@@ -375,7 +375,7 @@ def task_outcome
date_of_birth: claim.date_of_birth,
name: "#{claim.first_name} Except",
national_insurance_number: claim.national_insurance_number,
- teacher_reference_number: claim.teacher_reference_number
+ teacher_reference_number: claim.eligibility.teacher_reference_number
}
end
@@ -431,7 +431,7 @@ def task_outcome
date_of_birth: claim.date_of_birth,
name: "#{claim.first_name} Middle Names #{claim.surname}",
national_insurance_number: claim.national_insurance_number,
- teacher_reference_number: claim.teacher_reference_number
+ teacher_reference_number: claim.eligibility.teacher_reference_number
}
end
@@ -470,7 +470,7 @@ def task_outcome
date_of_birth: claim.date_of_birth + 1.day,
name: "#{claim.first_name} #{claim.surname}",
national_insurance_number: claim.national_insurance_number,
- teacher_reference_number: claim.teacher_reference_number
+ teacher_reference_number: claim.eligibility.teacher_reference_number
}
end
@@ -568,7 +568,7 @@ def task_outcome
date_of_birth: claim.date_of_birth,
name: "#{claim.first_name} #{claim.surname}",
national_insurance_number: claim.national_insurance_number,
- teacher_reference_number: claim.teacher_reference_number
+ teacher_reference_number: claim.eligibility.teacher_reference_number
}
end
@@ -626,7 +626,7 @@ def task_outcome
date_of_birth: claim.date_of_birth + 1.day,
name: "Except #{claim.surname}",
national_insurance_number: claim.national_insurance_number,
- teacher_reference_number: claim.teacher_reference_number
+ teacher_reference_number: claim.eligibility.teacher_reference_number
}
end
@@ -1008,7 +1008,7 @@ def task_outcome
date_of_birth: claim.date_of_birth,
name: "#{claim.first_name} #{claim.surname}",
national_insurance_number: claim.national_insurance_number,
- teacher_reference_number: claim.teacher_reference_number
+ teacher_reference_number: claim.eligibility.teacher_reference_number
}
end
@@ -1046,7 +1046,7 @@ def task_outcome
date_of_birth: claim.date_of_birth,
name: "#{claim.first_name} #{claim.surname}",
national_insurance_number: "QQ100000B",
- teacher_reference_number: claim.teacher_reference_number
+ teacher_reference_number: claim.eligibility.teacher_reference_number
}
end
@@ -1125,7 +1125,7 @@ def task_outcome
scenario "shows the notes added as part of automated identity checking" do
expect(notes).to include(
have_text("Teacher reference number not matched").and(
- have_text("Claimant: \"#{claim.teacher_reference_number}\"").and(
+ have_text("Claimant: \"#{claim.eligibility.teacher_reference_number}\"").and(
have_text("DQT: \"7654321\"").and(
have_text("by an automated check")
)
@@ -1154,7 +1154,7 @@ def task_outcome
date_of_birth: claim.date_of_birth,
name: "Except #{claim.surname}",
national_insurance_number: claim.national_insurance_number,
- teacher_reference_number: claim.teacher_reference_number
+ teacher_reference_number: claim.eligibility.teacher_reference_number
}
end
@@ -1210,7 +1210,7 @@ def task_outcome
date_of_birth: claim.date_of_birth,
name: "#{claim.first_name} Except",
national_insurance_number: claim.national_insurance_number,
- teacher_reference_number: claim.teacher_reference_number
+ teacher_reference_number: claim.eligibility.teacher_reference_number
}
end
@@ -1270,7 +1270,7 @@ def task_outcome
date_of_birth: claim.date_of_birth,
name: "#{claim.first_name} Middle Names #{claim.surname}",
national_insurance_number: claim.national_insurance_number,
- teacher_reference_number: claim.teacher_reference_number
+ teacher_reference_number: claim.eligibility.teacher_reference_number
}
end
@@ -1309,7 +1309,7 @@ def task_outcome
date_of_birth: claim.date_of_birth + 1.day,
name: "#{claim.first_name} #{claim.surname}",
national_insurance_number: claim.national_insurance_number,
- teacher_reference_number: claim.teacher_reference_number
+ teacher_reference_number: claim.eligibility.teacher_reference_number
}
end
@@ -1407,7 +1407,7 @@ def task_outcome
date_of_birth: claim.date_of_birth,
name: "#{claim.first_name} #{claim.surname}",
national_insurance_number: claim.national_insurance_number,
- teacher_reference_number: claim.teacher_reference_number
+ teacher_reference_number: claim.eligibility.teacher_reference_number
}
end
@@ -1461,7 +1461,7 @@ def task_outcome
date_of_birth: claim.date_of_birth + 1.day,
name: "Except #{claim.surname}",
national_insurance_number: claim.national_insurance_number,
- teacher_reference_number: claim.teacher_reference_number
+ teacher_reference_number: claim.eligibility.teacher_reference_number
}
end
diff --git a/spec/features/admin_claim_with_inconsistent_payroll_information_spec.rb b/spec/features/admin_claim_with_inconsistent_payroll_information_spec.rb
index 8763cd636c..e4c343df56 100644
--- a/spec/features/admin_claim_with_inconsistent_payroll_information_spec.rb
+++ b/spec/features/admin_claim_with_inconsistent_payroll_information_spec.rb
@@ -4,7 +4,7 @@
let(:personal_details) do
{
national_insurance_number: generate(:national_insurance_number),
- teacher_reference_number: generate(:teacher_reference_number),
+ eligibility_attributes: {teacher_reference_number: generate(:teacher_reference_number)},
date_of_birth: 30.years.ago.to_date,
student_loan_plan: StudentLoan::PLAN_1,
email_address: "email@example.com",
diff --git a/spec/features/admin_claim_with_matching_details_spec.rb b/spec/features/admin_claim_with_matching_details_spec.rb
index c77a32b59c..bb2220b9f5 100644
--- a/spec/features/admin_claim_with_matching_details_spec.rb
+++ b/spec/features/admin_claim_with_matching_details_spec.rb
@@ -9,7 +9,7 @@
scenario "service operator can check a claim with matching details" do
claim = create(:claim, :submitted, policy: Policies::StudentLoans)
- claim_with_matching_details = create(:claim, :submitted, teacher_reference_number: claim.teacher_reference_number)
+ claim_with_matching_details = create(:claim, :submitted, eligibility_attributes: {teacher_reference_number: claim.eligibility.teacher_reference_number})
click_on "View claims"
find("a[href='#{admin_claim_tasks_path(claim)}']").click
diff --git a/spec/features/admin_data_report_request_spec.rb b/spec/features/admin_data_report_request_spec.rb
index 4453b1b065..c34b3300a4 100644
--- a/spec/features/admin_data_report_request_spec.rb
+++ b/spec/features/admin_data_report_request_spec.rb
@@ -32,7 +32,7 @@
csv.each_with_index do |row, i|
claim = claims.detect { |c| c.reference == row["Claim reference"] }
expect(claim).not_to be_nil
- expect(row["Teacher reference number"]).to eq(claim.teacher_reference_number)
+ expect(row["Teacher reference number"]).to eq(claim.eligibility.teacher_reference_number)
expect(row["NINO"]).to eq(claim.national_insurance_number)
expect(row["Full name"]).to eq(claim.full_name)
expect(row["Email"]).to eq(claim.email_address)
diff --git a/spec/features/admin_search_spec.rb b/spec/features/admin_search_spec.rb
index 0a5b5f8735..98d61a1af5 100644
--- a/spec/features/admin_search_spec.rb
+++ b/spec/features/admin_search_spec.rb
@@ -18,7 +18,7 @@
expect(page).to have_content(claim1.reference)
expect(page).to have_no_content(claim2.reference)
- expect(page).to have_content(claim1.teacher_reference_number)
+ expect(page).to have_content(claim1.eligibility.teacher_reference_number)
expect(page).to have_content(claim1.policy.short_name)
end
@@ -35,7 +35,7 @@
expect(page).to have_content(claim1.reference)
expect(page).to have_no_content(claim2.reference)
- expect(page).to have_content(claim1.teacher_reference_number)
+ expect(page).to have_content(claim1.eligibility.teacher_reference_number)
expect(page).to have_content(claim1.policy.short_name)
end
diff --git a/spec/features/early_career_payments_claim_spec.rb b/spec/features/early_career_payments_claim_spec.rb
index 547d2a803e..75d65d87b5 100644
--- a/spec/features/early_career_payments_claim_spec.rb
+++ b/spec/features/early_career_payments_claim_spec.rb
@@ -246,7 +246,7 @@
expect(claim.bank_sort_code).to eq("123456")
expect(claim.bank_account_number).to eq("87654321")
expect(claim.payroll_gender).to eq("female")
- expect(claim.teacher_reference_number).to eq("1234567")
+ expect(claim.eligibility.teacher_reference_number).to eq("1234567")
expect(claim.reload.submitted_at).to eq(Time.zone.now)
policy_options_provided = [
{"policy" => "EarlyCareerPayments", "award_amount" => "5000.0"},
@@ -655,7 +655,7 @@
expect(claim.bank_sort_code).to eq("123456")
expect(claim.bank_account_number).to eq("87654321")
expect(claim.payroll_gender).to eq("female")
- expect(claim.teacher_reference_number).to eql("1234567")
+ expect(claim.eligibility.teacher_reference_number).to eql("1234567")
expect(claim.submitted_at).to eq(Time.zone.now)
policy_options_provided = [
{"policy" => "EarlyCareerPayments", "award_amount" => "5000.0"},
@@ -965,7 +965,7 @@
expect(submitted_claim.bank_sort_code).to eq("123456")
expect(submitted_claim.bank_account_number).to eq("87654321")
expect(submitted_claim.payroll_gender).to eq("female")
- expect(submitted_claim.teacher_reference_number).to eql("1234567")
+ expect(submitted_claim.eligibility.teacher_reference_number).to eql("1234567")
expect(submitted_claim.submitted_at).to eq(Time.zone.now)
policy_options_provided = [
diff --git a/spec/features/levelling_up_premium_payments_spec.rb b/spec/features/levelling_up_premium_payments_spec.rb
index 9ae995d42a..9e716ec98f 100644
--- a/spec/features/levelling_up_premium_payments_spec.rb
+++ b/spec/features/levelling_up_premium_payments_spec.rb
@@ -251,7 +251,7 @@ def submit_application
expect(submitted_claim.bank_sort_code).to eq("123456")
expect(submitted_claim.bank_account_number).to eq("87654321")
expect(submitted_claim.payroll_gender).to eq("female")
- expect(submitted_claim.teacher_reference_number).to eql("1234567")
+ expect(submitted_claim.eligibility.teacher_reference_number).to eql("1234567")
# - Application complete (make sure its Word for Word and styling matches)
expect(page).to have_text("You applied for a levelling up premium payment")
diff --git a/spec/helpers/admin/claims_helper_spec.rb b/spec/helpers/admin/claims_helper_spec.rb
index 12add2e93e..432dfb5ae7 100644
--- a/spec/helpers/admin/claims_helper_spec.rb
+++ b/spec/helpers/admin/claims_helper_spec.rb
@@ -10,14 +10,14 @@
:claim,
first_name: "Bruce",
surname: "Wayne",
- teacher_reference_number: "1234567",
national_insurance_number: "QQ123456C",
email_address: "test@email.com",
address_line_1: "Flat 1",
address_line_2: "1 Test Road",
address_line_3: "Test Town",
postcode: "AB1 2CD",
- date_of_birth: Date.new(1901, 1, 1)
+ date_of_birth: Date.new(1901, 1, 1),
+ eligibility_attributes: {teacher_reference_number: "1234567"}
)
end
@@ -35,7 +35,7 @@
end
context "when a claim has had personal data deleted" do
- let(:claim) { build(:claim, :rejected, :personal_data_removed, teacher_reference_number: "1234567", email_address: "test@email.com") }
+ let(:claim) { build(:claim, :rejected, :personal_data_removed, eligibility_attributes: {teacher_reference_number: "1234567"}, email_address: "test@email.com") }
it "returns the expected strings" do
expected_answers = [
@@ -176,23 +176,23 @@
let(:first_claim) {
build(
:claim,
- teacher_reference_number: "0902344",
national_insurance_number: "QQ891011C",
email_address: "genghis.khan@mongol-empire.com",
bank_account_number: "34682151",
bank_sort_code: "972654",
- building_society_roll_number: "123456789/ABCD"
+ building_society_roll_number: "123456789/ABCD",
+ eligibility_attributes: {teacher_reference_number: "0902344"}
)
}
let(:second_claim) {
build(
:claim,
:submitted,
- teacher_reference_number: first_claim.teacher_reference_number,
national_insurance_number: first_claim.national_insurance_number,
bank_account_number: first_claim.bank_account_number,
bank_sort_code: first_claim.bank_sort_code,
- building_society_roll_number: first_claim.building_society_roll_number
+ building_society_roll_number: first_claim.building_society_roll_number,
+ eligibility_attributes: {teacher_reference_number: first_claim.eligibility.teacher_reference_number}
)
}
subject { helper.matching_attributes(first_claim, second_claim) }
diff --git a/spec/jobs/qualifications_no_match_check_job_spec.rb b/spec/jobs/qualifications_no_match_check_job_spec.rb
index 0e81933d01..78868de968 100644
--- a/spec/jobs/qualifications_no_match_check_job_spec.rb
+++ b/spec/jobs/qualifications_no_match_check_job_spec.rb
@@ -3,7 +3,7 @@
RSpec.describe QualificationsNoMatchCheckJob do
before do
stub_qualified_teaching_statuses_show(
- trn: claim.teacher_reference_number,
+ trn: claim.eligibility.teacher_reference_number,
params: {
birthdate: claim.date_of_birth&.to_s,
nino: claim.national_insurance_number
diff --git a/spec/mailers/payment_mailer_spec.rb b/spec/mailers/payment_mailer_spec.rb
index de81bcf57c..90e3f04de0 100644
--- a/spec/mailers/payment_mailer_spec.rb
+++ b/spec/mailers/payment_mailer_spec.rb
@@ -96,18 +96,17 @@
context "with a payment with multiple claims" do
describe "#confirmation" do
let(:payment) { create(:payment, :confirmed, :with_figures, net_pay: 2500.00, student_loan_repayment: 60, claims: claims, scheduled_payment_date: Date.parse("2019-01-01")) }
- let(:student_loans_eligibility) { build(:student_loans_eligibility, :eligible, student_loan_repayment_amount: 500) }
+ let(:teacher_reference_number) { "1234567" }
let(:claims) do
personal_details = {
national_insurance_number: "JM603818B",
- teacher_reference_number: "1234567",
bank_sort_code: "112233",
bank_account_number: "95928482",
building_society_roll_number: nil
}
[
- build(:claim, :approved, personal_details.merge(eligibility: student_loans_eligibility)),
- build(:claim, :approved, personal_details.merge(policy: Policies::EarlyCareerPayments))
+ build(:claim, :approved, personal_details.merge(eligibility_attributes: {student_loan_repayment_amount: 500, teacher_reference_number: teacher_reference_number})),
+ build(:claim, :approved, personal_details.merge(policy: Policies::EarlyCareerPayments, eligibility_attributes: {teacher_reference_number: teacher_reference_number}))
]
end
let(:mail) { PaymentMailer.confirmation(payment) }
diff --git a/spec/models/amendment_spec.rb b/spec/models/amendment_spec.rb
index 7bc5388869..17d11794d0 100644
--- a/spec/models/amendment_spec.rb
+++ b/spec/models/amendment_spec.rb
@@ -33,7 +33,7 @@
let(:claim) {
create(:claim,
:submitted,
- teacher_reference_number: "1234567",
+ eligibility_attributes: {teacher_reference_number: "1234567"},
bank_sort_code: "111213",
bank_account_number: "12345678",
building_society_roll_number: nil,
@@ -45,7 +45,7 @@
context "given valid claim attributes and valid amendment attributes" do
let(:claim_attributes) do
{
- teacher_reference_number: "7654321",
+ eligibility_attributes: {teacher_reference_number: "7654321"},
bank_account_number: "87654321"
}
end
@@ -66,7 +66,7 @@
expect(amendment.created_by).to eq(dfe_signin_user)
expect(claim.reload.amendments).to eq([amendment])
- expect(claim.teacher_reference_number).to eq("7654321")
+ expect(claim.eligibility.teacher_reference_number).to eq("7654321")
expect(claim.bank_account_number).to eq("87654321")
end
end
@@ -74,7 +74,7 @@
context "given valid claim attributes and missing amendment notes" do
let(:claim_attributes) do
{
- teacher_reference_number: "7654321",
+ eligibility_attributes: {teacher_reference_number: "7654321"},
bank_account_number: "87654321"
}
end
@@ -92,11 +92,11 @@
expect(amendment.claim_changes).to eq("teacher_reference_number" => ["1234567", "7654321"], "bank_account_number" => ["12345678", "87654321"])
expect(amendment.created_by).to eq(dfe_signin_user)
- expect(claim.teacher_reference_number).to eq("7654321")
+ expect(claim.eligibility.teacher_reference_number).to eq("7654321")
expect(claim.bank_account_number).to eq("87654321")
expect(claim.reload.amendments).to be_empty
- expect(claim.teacher_reference_number).to eq("1234567")
+ expect(claim.eligibility.teacher_reference_number).to eq("1234567")
expect(claim.bank_account_number).to eq("12345678")
expect(amendment.errors.attribute_names).to eq([:notes])
@@ -106,7 +106,7 @@
context "given invalid claim attributes and valid amendment attributes" do
let(:claim_attributes) do
{
- teacher_reference_number: "765432",
+ eligibility_attributes: {teacher_reference_number: "765432"},
bank_account_number: "87654321"
}
end
@@ -117,27 +117,58 @@
}
end
- it "assigns the new values to the claim but does not persist them, and returns a non-persisted amendment, with the errors from the claim copied to the amendment’s errors" do
+ it "assigns the new values to the claim but does not persist them, and returns a non-persisted amendment, with the errors from the claim copied to the amendment's errors" do
amendment = described_class.amend_claim(claim, claim_attributes, amendment_attributes)
expect(amendment).to_not be_persisted
expect(amendment.created_by).to eq(dfe_signin_user)
- expect(claim.teacher_reference_number).to eq("765432")
+ expect(claim.eligibility.teacher_reference_number).to eq("765432")
expect(claim.bank_account_number).to eq("87654321")
expect(claim.reload.amendments).to be_empty
- expect(claim.teacher_reference_number).to eq("1234567")
+ expect(claim.eligibility.teacher_reference_number).to eq("1234567")
expect(claim.bank_account_number).to eq("12345678")
- expect(amendment.errors.attribute_names).to match_array([:teacher_reference_number])
+ expect(amendment.errors.attribute_names).to match_array([:"eligibility.teacher_reference_number"])
+ end
+ end
+
+ context "given invalid claim attributes (blank trn) and valid amendment attributes" do
+ let(:claim_attributes) do
+ {
+ eligibility_attributes: {teacher_reference_number: ""},
+ bank_account_number: "87654321"
+ }
+ end
+ let(:amendment_attributes) do
+ {
+ notes: "This is a change",
+ created_by: dfe_signin_user
+ }
+ end
+
+ it "assigns the new values to the claim but does not persist them, and returns a non-persisted amendment, with the errors from the claim copied to the amendment's errors" do
+ amendment = described_class.amend_claim(claim, claim_attributes, amendment_attributes)
+
+ expect(amendment).to_not be_persisted
+ expect(amendment.created_by).to eq(dfe_signin_user)
+
+ expect(claim.eligibility.teacher_reference_number).to eq("")
+ expect(claim.bank_account_number).to eq("87654321")
+
+ expect(claim.reload.amendments).to be_empty
+ expect(claim.eligibility.teacher_reference_number).to eq("1234567")
+ expect(claim.bank_account_number).to eq("12345678")
+
+ expect(amendment.errors.attribute_names).to match_array([:"eligibility.teacher_reference_number"])
end
end
context "given invalid claim attributes and missing amendment notes" do
let(:claim_attributes) do
{
- teacher_reference_number: "765432",
+ eligibility_attributes: {teacher_reference_number: "765432"},
bank_account_number: "87654321"
}
end
@@ -147,27 +178,27 @@
}
end
- it "assigns the new values to the claim but does not persist them, and returns a non-persisted amendment which has errors, with the errors from the claim copied to the amendment’s errors" do
+ it "assigns the new values to the claim but does not persist them, and returns a non-persisted amendment which has errors, with the errors from the claim copied to the amendment's errors" do
amendment = described_class.amend_claim(claim, claim_attributes, amendment_attributes)
expect(amendment).to_not be_persisted
expect(amendment.created_by).to eq(dfe_signin_user)
- expect(claim.teacher_reference_number).to eq("765432")
+ expect(claim.eligibility.teacher_reference_number).to eq("765432")
expect(claim.bank_account_number).to eq("87654321")
expect(claim.reload.amendments).to be_empty
- expect(claim.teacher_reference_number).to eq("1234567")
+ expect(claim.eligibility.teacher_reference_number).to eq("1234567")
expect(claim.bank_account_number).to eq("12345678")
- expect(amendment.errors.attribute_names).to match_array([:notes, :teacher_reference_number])
+ expect(amendment.errors.attribute_names).to match_array([:notes, :"eligibility.teacher_reference_number"])
end
end
context "given claim attributes which are all the same as the current values" do
let(:claim_attributes) do
{
- teacher_reference_number: claim.teacher_reference_number
+ eligibility_attributes: {teacher_reference_number: claim.eligibility.teacher_reference_number}
}
end
let(:amendment_attributes) do
@@ -178,7 +209,7 @@
end
it "returns a non-persisted amendment which has errors on claim_changes" do
- amendment = described_class.amend_claim(claim, claim_attributes, amendment_attributes)
+ amendment = described_class.amend_claim(claim.reload, claim_attributes, amendment_attributes)
expect(amendment).to_not be_persisted
expect(claim.reload.amendments).to be_empty
@@ -200,14 +231,14 @@
}
end
- it "stores the normalised value in the amendment’s claim_changes" do
- amendment = described_class.amend_claim(claim, claim_attributes, amendment_attributes)
+ it "stores the normalised value in the amendment's claim_changes" do
+ amendment = described_class.amend_claim(claim.reload, claim_attributes, amendment_attributes)
expect(amendment.claim_changes).to eq("bank_sort_code" => ["111213", "010203"])
end
end
- context "when amending the claim’s eligibility attributes" do
+ context "when amending the claim's eligibility attributes" do
context "with a Student Loans (TSLR) claim" do
let(:claim) do
create(:claim, :submitted, eligibility: build(:student_loans_eligibility, :eligible, student_loan_repayment_amount: 1000))
@@ -215,9 +246,7 @@
let(:claim_attributes) do
{
- eligibility_attributes: {
- student_loan_repayment_amount: 555
- }
+ eligibility_attributes: {student_loan_repayment_amount: 555}
}
end
let(:amendment_attributes) do
@@ -227,8 +256,8 @@
}
end
- it "stores the value in the amendment’s claim_changes" do
- amendment = described_class.amend_claim(claim, claim_attributes, amendment_attributes)
+ it "stores the value in the amendment's claim_changes" do
+ amendment = described_class.amend_claim(claim.reload, claim_attributes, amendment_attributes)
expect(amendment.claim_changes).to eq("student_loan_repayment_amount" => [1000, 555])
end
@@ -295,7 +324,7 @@
before { create(:journey_configuration, :additional_payments) }
- it "stores the value in the amendment’s claim_changes" do
+ it "stores the value in the amendment's claim_changes" do
amendment = described_class.amend_claim(claim, claim_attributes, amendment_attributes)
expect(amendment.claim_changes).to eq("award_amount" => [7_500, 2_500])
@@ -306,7 +335,7 @@
context "when updating a value from nil to an empty string" do
let(:claim_attributes) do
{
- teacher_reference_number: "7654321",
+ eligibility_attributes: {teacher_reference_number: "7654321"},
building_society_roll_number: ""
}
end
@@ -317,7 +346,7 @@
}
end
- it "does not mark the value as changed in the amendment’s claim_changes" do
+ it "does not mark the value as changed in the amendment's claim_changes" do
amendment = described_class.amend_claim(claim, claim_attributes, amendment_attributes)
expect(amendment.claim_changes).to eq("teacher_reference_number" => ["1234567", "7654321"])
diff --git a/spec/models/automated_checks/claim_verifiers/census_subjects_taught_spec.rb b/spec/models/automated_checks/claim_verifiers/census_subjects_taught_spec.rb
index 0261efb5e5..48dd56f4ac 100644
--- a/spec/models/automated_checks/claim_verifiers/census_subjects_taught_spec.rb
+++ b/spec/models/automated_checks/claim_verifiers/census_subjects_taught_spec.rb
@@ -14,7 +14,6 @@ module ClaimVerifiers
national_insurance_number: "RT901113D",
reference: "QKCVAQ3K",
surname: "Bonnet-Fontaine",
- teacher_reference_number: teacher_reference_number,
policy: policy
)
@@ -23,7 +22,8 @@ module ClaimVerifiers
attributes_for(
:"#{policy_underscored}_eligibility",
:eligible,
- eligible_itt_subject: :mathematics
+ eligible_itt_subject: :mathematics,
+ teacher_reference_number: teacher_reference_number
)
)
elsif policy == Policies::LevellingUpPremiumPayments
@@ -31,7 +31,8 @@ module ClaimVerifiers
attributes_for(
:"#{policy_underscored}_eligibility",
:eligible,
- eligible_itt_subject: :computing
+ eligible_itt_subject: :computing,
+ teacher_reference_number: teacher_reference_number
)
)
elsif policy == Policies::StudentLoans
@@ -41,7 +42,8 @@ module ClaimVerifiers
:eligible,
biology_taught: true,
computing_taught: true,
- physics_taught: false
+ physics_taught: false,
+ teacher_reference_number: teacher_reference_number
)
)
end
@@ -89,7 +91,6 @@ module ClaimVerifiers
national_insurance_number: "RT901113D",
reference: "QKCVAQ3K",
surname: "Bonnet-Fontaine",
- teacher_reference_number: teacher_reference_number,
policy: policy
)
@@ -98,7 +99,8 @@ module ClaimVerifiers
attributes_for(
:"#{policy_underscored}_eligibility",
:eligible,
- eligible_itt_subject: :none_of_the_above
+ eligible_itt_subject: :none_of_the_above,
+ teacher_reference_number: teacher_reference_number
)
)
elsif policy == Policies::LevellingUpPremiumPayments
@@ -106,7 +108,8 @@ module ClaimVerifiers
attributes_for(
:"#{policy_underscored}_eligibility",
:eligible,
- eligible_itt_subject: :none_of_the_above
+ eligible_itt_subject: :none_of_the_above,
+ teacher_reference_number: teacher_reference_number
)
)
elsif policy == Policies::StudentLoans
@@ -116,7 +119,8 @@ module ClaimVerifiers
:eligible,
biology_taught: false,
computing_taught: false,
- physics_taught: false
+ physics_taught: false,
+ teacher_reference_number: teacher_reference_number
)
)
end
@@ -344,9 +348,9 @@ module ClaimVerifiers
national_insurance_number: "RT901113D",
reference: "QKCVAQ3K",
surname: "Bonnet-Fontaine",
- teacher_reference_number: teacher_reference_number,
policy: policy,
- tasks: [build(:task, name: :census_subjects_taught)]
+ tasks: [build(:task, name: :census_subjects_taught)],
+ eligibility_attributes: {teacher_reference_number: teacher_reference_number}
)
end
@@ -405,7 +409,6 @@ module ClaimVerifiers
national_insurance_number: "RT901113D",
reference: "QKCVAQ3K",
surname: "Bonnet-Fontaine",
- teacher_reference_number: teacher_reference_number,
policy: Policies::StudentLoans
)
@@ -416,7 +419,8 @@ module ClaimVerifiers
biology_taught: false,
computing_taught: false,
physics_taught: false,
- languages_taught: true
+ languages_taught: true,
+ teacher_reference_number: teacher_reference_number
)
)
diff --git a/spec/models/automated_checks/claim_verifiers/employment_spec.rb b/spec/models/automated_checks/claim_verifiers/employment_spec.rb
index facbf0ce9b..1f428b900e 100644
--- a/spec/models/automated_checks/claim_verifiers/employment_spec.rb
+++ b/spec/models/automated_checks/claim_verifiers/employment_spec.rb
@@ -24,7 +24,6 @@ module ClaimVerifiers
national_insurance_number: "RT901113D",
reference: "QKCVAQ3K",
surname: "Bonnet-Fontaine",
- teacher_reference_number: teacher_reference_number,
policy: policy,
submitted_at: DateTime.new(2022, 1, 12, 13, 0, 0)
)
@@ -33,7 +32,8 @@ module ClaimVerifiers
attributes_for(
:"#{policy_underscored}_eligibility",
:eligible,
- current_school_id: school.id
+ current_school_id: school.id,
+ teacher_reference_number: teacher_reference_number
)
)
diff --git a/spec/models/automated_checks/claim_verifiers/identity_spec.rb b/spec/models/automated_checks/claim_verifiers/identity_spec.rb
index 4a7e6df081..b5e18c3aa4 100644
--- a/spec/models/automated_checks/claim_verifiers/identity_spec.rb
+++ b/spec/models/automated_checks/claim_verifiers/identity_spec.rb
@@ -17,7 +17,7 @@ module ClaimVerifiers
end
stub_qualified_teaching_statuses_show(
- trn: claim_arg.teacher_reference_number,
+ trn: claim_arg.eligibility.teacher_reference_number,
params: {
birthdate: claim_arg.date_of_birth&.to_s,
nino: claim_arg.national_insurance_number
@@ -36,7 +36,6 @@ module ClaimVerifiers
national_insurance_number: "QQ100000C",
reference: "AB123456",
surname: "ELIGIBLE",
- teacher_reference_number: "1234567",
policy: policy
)
@@ -45,7 +44,8 @@ module ClaimVerifiers
claim.eligibility.update!(
attributes_for(
:"#{policy_underscored}_eligibility",
- :eligible
+ :eligible,
+ teacher_reference_number: "1234567"
)
)
@@ -56,7 +56,7 @@ module ClaimVerifiers
{
claim: claim_arg,
dqt_teacher_status: Dqt::Client.new.teacher.find(
- claim_arg.teacher_reference_number,
+ claim_arg.eligibility.teacher_reference_number,
birthdate: claim_arg.date_of_birth,
nino: claim_arg.national_insurance_number
)
@@ -79,7 +79,7 @@ module ClaimVerifiers
dob: claim_arg.date_of_birth,
name: claim_arg.full_name,
nino: claim_arg.national_insurance_number,
- trn: claim_arg.teacher_reference_number
+ trn: claim_arg.eligibility.teacher_reference_number
}
end
@@ -554,7 +554,7 @@ module ClaimVerifiers
reference: "AB123456",
surname: "ELIGIBLE",
tasks: [build(:task, name: :identity_confirmation)],
- teacher_reference_number: "1234567"
+ eligibility_attributes: {teacher_reference_number: "1234567"}
)
end
@@ -675,7 +675,6 @@ module ClaimVerifiers
national_insurance_number: " QQ100000C ",
reference: "AB123456",
surname: "ELIGIBLE ",
- teacher_reference_number: " 1234567 ",
policy: policy
)
@@ -684,7 +683,8 @@ module ClaimVerifiers
claim.eligibility.update!(
attributes_for(
:"#{policy_underscored}_eligibility",
- :eligible
+ :eligible,
+ teacher_reference_number: " 1234567 "
)
)
diff --git a/spec/models/automated_checks/claim_verifiers/induction_spec.rb b/spec/models/automated_checks/claim_verifiers/induction_spec.rb
index 9a2f081ed0..7edd71f081 100644
--- a/spec/models/automated_checks/claim_verifiers/induction_spec.rb
+++ b/spec/models/automated_checks/claim_verifiers/induction_spec.rb
@@ -9,7 +9,7 @@ module ClaimVerifiers
{
claim: claim_arg,
dqt_teacher_status: Dqt::Client.new.teacher.find(
- claim_arg.teacher_reference_number,
+ claim_arg.eligibility.teacher_reference_number,
birthdate: claim_arg.date_of_birth,
nino: claim_arg.national_insurance_number
)
@@ -30,7 +30,7 @@ module ClaimVerifiers
end
stub_qualified_teaching_statuses_show(
- trn: claim_arg.teacher_reference_number,
+ trn: claim_arg.eligibility.teacher_reference_number,
params: {
birthdate: claim_arg.date_of_birth&.to_s,
nino: claim_arg.national_insurance_number
diff --git a/spec/models/automated_checks/claim_verifiers/qualifications_spec.rb b/spec/models/automated_checks/claim_verifiers/qualifications_spec.rb
index e6287827ac..087ea5f231 100644
--- a/spec/models/automated_checks/claim_verifiers/qualifications_spec.rb
+++ b/spec/models/automated_checks/claim_verifiers/qualifications_spec.rb
@@ -17,7 +17,7 @@ module ClaimVerifiers
end
stub_qualified_teaching_statuses_show(
- trn: claim_arg.teacher_reference_number,
+ trn: claim_arg.eligibility.teacher_reference_number,
params: {
birthdate: claim_arg.date_of_birth&.to_s,
nino: claim_arg.national_insurance_number
@@ -38,7 +38,6 @@ module ClaimVerifiers
national_insurance_number: "QQ100000C",
reference: "AB123456",
surname: "ELIGIBLE",
- teacher_reference_number: "1234567",
policy: Policies::EarlyCareerPayments
)
@@ -46,7 +45,8 @@ module ClaimVerifiers
attributes_for(
:early_career_payments_eligibility,
:eligible,
- qualification: :undergraduate_itt
+ qualification: :undergraduate_itt,
+ teacher_reference_number: "1234567"
)
)
@@ -57,7 +57,7 @@ module ClaimVerifiers
{
claim: claim_arg,
dqt_teacher_status: Dqt::Client.new.teacher.find(
- claim_arg.teacher_reference_number,
+ claim_arg.eligibility.teacher_reference_number,
birthdate: claim_arg.date_of_birth,
nino: claim_arg.national_insurance_number
)
@@ -331,7 +331,7 @@ module ClaimVerifiers
reference: "AB123456",
surname: "ELIGIBLE",
tasks: [build(:task, name: :qualifications)],
- teacher_reference_number: "1234567"
+ eligibility_attributes: {teacher_reference_number: "1234567"}
)
end
diff --git a/spec/models/base_policy_spec.rb b/spec/models/base_policy_spec.rb
index 6f0ca71125..abc200c266 100644
--- a/spec/models/base_policy_spec.rb
+++ b/spec/models/base_policy_spec.rb
@@ -1,10 +1,40 @@
require "rails_helper"
module Policies
+ module TestPolicyA
+ include BasePolicy
+
+ extend self
+
+ class Eligibility
+ end
+ end
+
+ module TestPolicyB
+ include BasePolicy
+
+ extend self
+
+ class Eligibility
+ end
+ end
+
module TestPolicy
include BasePolicy
extend self
+
+ OTHER_CLAIMABLE_POLICIES = [
+ TestPolicyA,
+ TestPolicyB
+ ].freeze
+
+ ELIGIBILITY_MATCHING_ATTRIBUTES = [["some_reference"]].freeze
+
+ SEARCHABLE_ELIGIBILITY_ATTRIBUTES = %w[some_searchable_reference].freeze
+
+ class Eligibility
+ end
end
end
@@ -38,4 +68,48 @@ module TestPolicy
expect(Policies::TestPolicy.locale_key).to eq("test_policy")
end
end
+
+ describe "::policies_claimable" do
+ it do
+ expect(Policies::TestPolicy.policies_claimable).to contain_exactly(
+ Policies::TestPolicy, Policies::TestPolicyA, Policies::TestPolicyB
+ )
+ end
+
+ it do
+ expect(Policies::TestPolicyA.policies_claimable).to be_empty
+ end
+ end
+
+ describe "::policy_eligibilities_claimable" do
+ it do
+ expect(Policies::TestPolicy.policy_eligibilities_claimable).to contain_exactly(
+ Policies::TestPolicy::Eligibility, Policies::TestPolicyA::Eligibility, Policies::TestPolicyB::Eligibility
+ )
+ end
+
+ it do
+ expect(Policies::TestPolicyA.policy_eligibilities_claimable).to be_empty
+ end
+ end
+
+ describe "::eligibility_matching_attributes" do
+ it do
+ expect(Policies::TestPolicy.eligibility_matching_attributes).to contain_exactly(["some_reference"])
+ end
+
+ it do
+ expect(Policies::TestPolicyA.eligibility_matching_attributes).to be_empty
+ end
+ end
+
+ describe "::searchable_eligibility_attributes" do
+ it do
+ expect(Policies::TestPolicy.searchable_eligibility_attributes).to contain_exactly("some_searchable_reference")
+ end
+
+ it do
+ expect(Policies::TestPolicyA.searchable_eligibility_attributes).to be_empty
+ end
+ end
end
diff --git a/spec/models/claim/claims_preventing_payment_finder_spec.rb b/spec/models/claim/claims_preventing_payment_finder_spec.rb
index 1af1abfd4e..5311772fdc 100644
--- a/spec/models/claim/claims_preventing_payment_finder_spec.rb
+++ b/spec/models/claim/claims_preventing_payment_finder_spec.rb
@@ -8,10 +8,10 @@
describe "#claims_preventing_payment" do
let(:personal_details) do
{
- teacher_reference_number: generate(:teacher_reference_number),
bank_account_number: "32828838",
bank_sort_code: "183828",
- first_name: "Boris"
+ first_name: "Boris",
+ eligibility_attributes: {teacher_reference_number: generate(:teacher_reference_number)}
}
end
let(:claim) { create(:claim, :submitted, personal_details) }
@@ -42,7 +42,9 @@
end
it "includes the other claim where a topup is payrollable" do
- lup_eligibility = create(:levelling_up_premium_payments_eligibility, :eligible, award_amount: 1500.0)
+ eligibility_attributes = inconsistent_personal_details.delete(:eligibility_attributes)
+
+ lup_eligibility = create(:levelling_up_premium_payments_eligibility, :eligible, award_amount: 1500.0, **eligibility_attributes)
other_claim = create(:claim, :approved, inconsistent_personal_details.merge(policy: Policies::LevellingUpPremiumPayments, eligibility: lup_eligibility))
create(:payment, claims: [other_claim])
other_claim.topups.create(award_amount: "500.00", created_by: user)
diff --git a/spec/models/claim/data_report_request_spec.rb b/spec/models/claim/data_report_request_spec.rb
index e61f14e5fa..d65834550a 100644
--- a/spec/models/claim/data_report_request_spec.rb
+++ b/spec/models/claim/data_report_request_spec.rb
@@ -21,7 +21,7 @@
it "contains the correct values" do
claims.each_with_index do |claim, index|
expect(report_request_csv[index].fields("Claim reference")).to include(claim.reference)
- expect(report_request_csv[index].fields("Teacher reference number")).to include(claim.teacher_reference_number)
+ expect(report_request_csv[index].fields("Teacher reference number")).to include(claim.eligibility.teacher_reference_number)
expect(report_request_csv[index].fields("NINO")).to include(claim.national_insurance_number)
expect(report_request_csv[index].fields("Full name")).to include(claim.full_name)
expect(report_request_csv[index].fields("Email")).to include(claim.email_address)
@@ -54,7 +54,7 @@
it "contains the correct values" do
claims.each_with_index do |claim, index|
expect(report_request_csv[index].fields("Claim reference")).to include(claim.reference)
- expect(report_request_csv[index].fields("Teacher reference number")).to include(claim.teacher_reference_number)
+ expect(report_request_csv[index].fields("Teacher reference number")).to include(claim.eligibility.teacher_reference_number)
expect(report_request_csv[index].fields("NINO")).to include(claim.national_insurance_number)
expect(report_request_csv[index].fields("Full name")).to include(claim.full_name)
expect(report_request_csv[index].fields("Email")).to include(claim.email_address)
diff --git a/spec/models/claim/matching_attribute_finder_spec.rb b/spec/models/claim/matching_attribute_finder_spec.rb
index e2b67f5d6f..c1e868a0dd 100644
--- a/spec/models/claim/matching_attribute_finder_spec.rb
+++ b/spec/models/claim/matching_attribute_finder_spec.rb
@@ -4,40 +4,40 @@
describe "#matching_claims for ECP/LUP claims" do
let!(:source_claim) {
create(:claim,
- teacher_reference_number: "0902344",
national_insurance_number: "QQ891011C",
email_address: "genghis.khan@mongol-empire.com",
bank_account_number: "34682151",
bank_sort_code: "972654",
academic_year: AcademicYear.new("2019"),
building_society_roll_number: "123456789/ABCD",
- policy: Policies::EarlyCareerPayments)
+ policy: Policies::EarlyCareerPayments,
+ eligibility_attributes: {teacher_reference_number: "0902344"})
}
let!(:student_loans_claim) {
create(:claim,
:submitted,
- teacher_reference_number: "0902344",
national_insurance_number: "QQ891011C",
email_address: "genghis.khan@mongol-empire.com",
bank_account_number: "34682151",
bank_sort_code: "972654",
academic_year: AcademicYear.new("2019"),
building_society_roll_number: "123456789/ABCD",
- policy: Policies::StudentLoans)
+ policy: Policies::StudentLoans,
+ eligibility_attributes: {teacher_reference_number: "0902344"})
}
let!(:lup_claim) {
create(:claim,
:submitted,
- teacher_reference_number: "0902344",
national_insurance_number: "QQ891011C",
email_address: "genghis.khan@mongol-empire.com",
bank_account_number: "34682151",
bank_sort_code: "972654",
academic_year: AcademicYear.new("2019"),
building_society_roll_number: "123456789/ABCD",
- policy: Policies::LevellingUpPremiumPayments)
+ policy: Policies::LevellingUpPremiumPayments,
+ eligibility_attributes: {teacher_reference_number: "0902344"})
}
subject(:matching_claims) { Claim::MatchingAttributeFinder.new(source_claim).matching_claims }
@@ -50,14 +50,14 @@
describe "#matching_claims" do
let(:source_claim) {
create(:claim,
- teacher_reference_number: "0902344",
national_insurance_number: "QQ891011C",
email_address: "genghis.khan@mongol-empire.com",
bank_account_number: "34682151",
bank_sort_code: "972654",
academic_year: AcademicYear.new("2019"),
building_society_roll_number: "123456789/ABCD",
- policy: Policies::StudentLoans)
+ policy: Policies::StudentLoans,
+ eligibility_attributes: {teacher_reference_number: "0902344"})
}
subject(:matching_claims) { Claim::MatchingAttributeFinder.new(source_claim).matching_claims }
@@ -73,20 +73,20 @@
end
it "does not include unsubmitted claims with matching attributes" do
- create(:claim, :submittable, teacher_reference_number: source_claim.teacher_reference_number)
+ create(:claim, :submittable, eligibility_attributes: {teacher_reference_number: source_claim.eligibility.teacher_reference_number})
expect(matching_claims).to be_empty
end
it "does not include claims that match, but have a different policy" do
- student_loans_claim = create(:claim, :submitted, teacher_reference_number: source_claim.teacher_reference_number, policy: Policies::StudentLoans)
+ student_loans_claim = create(:claim, :submitted, eligibility_attributes: {teacher_reference_number: source_claim.eligibility.teacher_reference_number}, policy: Policies::StudentLoans)
expect(matching_claims).to contain_exactly(student_loans_claim)
end
it "does not include claims that match, but have a different academic year" do
create(:claim, :submitted,
- teacher_reference_number: source_claim.teacher_reference_number,
+ eligibility_attributes: {teacher_reference_number: source_claim.eligibility.teacher_reference_number},
academic_year: AcademicYear.new("2020"),
policy: source_claim.policy)
@@ -94,7 +94,7 @@
end
it "includes a claim with a matching teacher reference number" do
- claim_with_matching_attribute = create(:claim, :submitted, teacher_reference_number: source_claim.teacher_reference_number)
+ claim_with_matching_attribute = create(:claim, :submitted, eligibility_attributes: {teacher_reference_number: source_claim.eligibility.teacher_reference_number})
expect(matching_claims).to eq([claim_with_matching_attribute])
end
diff --git a/spec/models/claim/personal_data_scrubber_spec.rb b/spec/models/claim/personal_data_scrubber_spec.rb
index 10e8359a40..88e72b4511 100644
--- a/spec/models/claim/personal_data_scrubber_spec.rb
+++ b/spec/models/claim/personal_data_scrubber_spec.rb
@@ -181,7 +181,7 @@
travel_to last_academic_year - 1.week do
claim = create(:claim, :submitted)
amendment = create(:amendment, claim: claim, claim_changes: {
- "teacher_reference_number" => [generate(:teacher_reference_number).to_s, claim.teacher_reference_number],
+ "teacher_reference_number" => [generate(:teacher_reference_number).to_s, claim.eligibility.teacher_reference_number],
"payroll_gender" => ["male", claim.payroll_gender],
"date_of_birth" => [25.years.ago.to_date, claim.date_of_birth],
"student_loan_plan" => ["plan_1", claim.student_loan_plan],
diff --git a/spec/models/claim/search_spec.rb b/spec/models/claim/search_spec.rb
index 82a024c346..65c569a417 100644
--- a/spec/models/claim/search_spec.rb
+++ b/spec/models/claim/search_spec.rb
@@ -94,7 +94,7 @@
end
context "search by teacher reference number" do
- let(:claim) { create(:claim, :submitted, teacher_reference_number: teacher_reference_number) }
+ let!(:claim) { create(:claim, :submitted, eligibility_attributes: {teacher_reference_number: teacher_reference_number}) }
context "matches" do
let(:query) { teacher_reference_number }
@@ -109,7 +109,7 @@
end
context "multiple matches" do
- let(:historical_matching_claim) { create(:claim, :submitted, teacher_reference_number: teacher_reference_number) }
+ let!(:historical_matching_claim) { create(:claim, :submitted, eligibility_attributes: {teacher_reference_number: teacher_reference_number}) }
let(:query) { teacher_reference_number }
specify { expect(search.claims).to contain_exactly(claim, historical_matching_claim) }
diff --git a/spec/models/claim_auto_approval_spec.rb b/spec/models/claim_auto_approval_spec.rb
index f394da79f4..b7b75d9a95 100644
--- a/spec/models/claim_auto_approval_spec.rb
+++ b/spec/models/claim_auto_approval_spec.rb
@@ -29,7 +29,7 @@
context "when the claim is a duplicate" do
let(:claim) { create(:claim, :submitted) }
- let!(:duplicate) { create(:claim, :submitted, teacher_reference_number: claim.teacher_reference_number, policy: claim.policy) }
+ let!(:duplicate) { create(:claim, :submitted, eligibility_attributes: {teacher_reference_number: claim.eligibility.teacher_reference_number}, policy: claim.policy) }
it { is_expected.to eq(false) }
end
diff --git a/spec/models/claim_checking_tasks_spec.rb b/spec/models/claim_checking_tasks_spec.rb
index d39e04ea4c..cdd181bded 100644
--- a/spec/models/claim_checking_tasks_spec.rb
+++ b/spec/models/claim_checking_tasks_spec.rb
@@ -29,7 +29,7 @@
shared_examples :matching_details_task do
it "includes a task for matching details when there are claims with matching details" do
- create(:claim, :submitted, policy:, teacher_reference_number: claim.teacher_reference_number)
+ create(:claim, :submitted, policy:, eligibility_attributes: {teacher_reference_number: claim.eligibility.teacher_reference_number})
expect(checking_tasks.applicable_task_names).to match_array(applicable_tasks + %w[matching_details])
end
@@ -135,7 +135,7 @@
end
end
- let!(:previous_claim) { create(:claim, :submitted, policy:, teacher_reference_number: claim.teacher_reference_number) }
+ let!(:previous_claim) { create(:claim, :submitted, policy:, eligibility_attributes: {teacher_reference_number: claim.eligibility.teacher_reference_number}) }
it { is_expected.to eq(false) }
end
diff --git a/spec/models/claim_spec.rb b/spec/models/claim_spec.rb
index a30f2c380d..ef5c807cab 100644
--- a/spec/models/claim_spec.rb
+++ b/spec/models/claim_spec.rb
@@ -43,9 +43,9 @@
context "that has a teacher_reference_number" do
it "validates the length of the teacher reference number" do
- expect(build(:claim, teacher_reference_number: "1/2/3/4/5/6/7")).to be_valid
- expect(build(:claim, teacher_reference_number: "1/2/3/4/5")).not_to be_valid
- expect(build(:claim, teacher_reference_number: "12/345678")).not_to be_valid
+ expect(build(:claim, eligibility_attributes: {teacher_reference_number: "1/2/3/4/5/6/7"}).eligibility).to be_valid
+ expect(build(:claim, eligibility_attributes: {teacher_reference_number: "1/2/3/4/5"}).eligibility).not_to be_valid
+ expect(build(:claim, eligibility_attributes: {teacher_reference_number: "12/345678"}).eligibility).not_to be_valid
end
end
@@ -109,20 +109,20 @@
end
describe "#teacher_reference_number" do
- let(:claim) { build(:claim, teacher_reference_number: teacher_reference_number) }
+ let(:claim) { build(:claim, eligibility_attributes: {teacher_reference_number: teacher_reference_number}) }
context "when the teacher reference number is stored and contains non digits" do
let(:teacher_reference_number) { "12\\23 /232 " }
it "strips out the non digits" do
claim.save!
- expect(claim.teacher_reference_number).to eql("1223232")
+ expect(claim.eligibility.teacher_reference_number).to eql("1223232")
end
end
context "before the teacher reference number is stored" do
let(:teacher_reference_number) { "12/34567" }
it "is not modified" do
- expect(claim.teacher_reference_number).to eql("12/34567")
+ expect(claim.eligibility.teacher_reference_number).to eql("12/34567")
end
end
end
@@ -328,9 +328,9 @@
it "returns false when there exists another payrollable claim with the same teacher reference number but with inconsistent attributes that would prevent us from running payroll" do
teacher_reference_number = generate(:teacher_reference_number)
- create(:claim, :approved, teacher_reference_number: teacher_reference_number, date_of_birth: 20.years.ago)
+ create(:claim, :approved, eligibility_attributes: {teacher_reference_number: teacher_reference_number}, date_of_birth: 20.years.ago)
- expect(create(:claim, :submitted, teacher_reference_number: teacher_reference_number, date_of_birth: 30.years.ago).approvable?).to eq false
+ expect(create(:claim, :submitted, eligibility_attributes: {teacher_reference_number: teacher_reference_number}, date_of_birth: 30.years.ago).approvable?).to eq false
end
context "when the claim is held" do
@@ -572,7 +572,6 @@
:address_line_4,
:postcode,
:payroll_gender,
- :teacher_reference_number,
:national_insurance_number,
:email_address,
:mobile_number,
@@ -592,7 +591,8 @@
:details_check,
:email_address_check,
:mobile_check,
- :qualifications_details_check
+ :qualifications_details_check,
+ :column_to_remove_teacher_reference_number
])
end
end
diff --git a/spec/models/decision_spec.rb b/spec/models/decision_spec.rb
index fb6e7ad41b..24adf8c05b 100644
--- a/spec/models/decision_spec.rb
+++ b/spec/models/decision_spec.rb
@@ -71,7 +71,7 @@
it "prevents a claim with matching bank details from being approved" do
personal_details = {
- teacher_reference_number: generate(:teacher_reference_number),
+ eligibility_attributes: {teacher_reference_number: generate(:teacher_reference_number)},
bank_sort_code: "112233"
}
diff --git a/spec/models/early_career_payments/eligibility_spec.rb b/spec/models/early_career_payments/eligibility_spec.rb
index 1fc2dd4073..c4e7f008a3 100644
--- a/spec/models/early_career_payments/eligibility_spec.rb
+++ b/spec/models/early_career_payments/eligibility_spec.rb
@@ -117,9 +117,9 @@
end
it "validates that the award_amount is less than £7,500 when amending a claim" do
- expect(Policies::EarlyCareerPayments::Eligibility.new(award_amount: 7_501)).not_to be_valid(:amendment)
- expect(Policies::EarlyCareerPayments::Eligibility.new(award_amount: 7_500)).to be_valid(:amendment)
- expect(Policies::EarlyCareerPayments::Eligibility.new(award_amount: 7_499)).to be_valid(:amendment)
+ expect(Policies::EarlyCareerPayments::Eligibility.new(teacher_reference_number: "1234567", award_amount: 7_501)).not_to be_valid(:amendment)
+ expect(Policies::EarlyCareerPayments::Eligibility.new(teacher_reference_number: "1234567", award_amount: 7_500)).to be_valid(:amendment)
+ expect(Policies::EarlyCareerPayments::Eligibility.new(teacher_reference_number: "1234567", award_amount: 7_499)).to be_valid(:amendment)
end
end
end
diff --git a/spec/models/payment_spec.rb b/spec/models/payment_spec.rb
index dc2d64a64c..eedf7abd15 100644
--- a/spec/models/payment_spec.rb
+++ b/spec/models/payment_spec.rb
@@ -71,7 +71,7 @@
let(:claims) do
build_list(:claim, 2, :approved,
national_insurance_number: "JM603818B",
- teacher_reference_number: "1234567",
+ eligibility_attributes: {teacher_reference_number: "1234567"},
email_address: "email@example.com",
bank_sort_code: "112233",
bank_account_number: "95928482",
@@ -97,7 +97,7 @@
end
it "is invalid when claims' teacher reference numbers do not match" do
- claims[0].teacher_reference_number = "9988776"
+ claims[0].eligibility.teacher_reference_number = "9988776"
expect(subject).not_to be_valid
expect(subject.errors[:claims]).to eq(["#{claims[0].reference} and #{claims[1].reference} have different values for teacher reference number"])
@@ -179,7 +179,7 @@
let(:claims) do
personal_details = {
national_insurance_number: "JM603818B",
- teacher_reference_number: "1234567",
+ eligibility_attributes: {teacher_reference_number: "1234567"},
bank_sort_code: "112233",
bank_account_number: "95928482",
building_society_roll_number: nil
@@ -201,7 +201,7 @@
let(:personal_details) do
{
national_insurance_number: generate(:national_insurance_number),
- teacher_reference_number: generate(:teacher_reference_number),
+ eligibility_attributes: {teacher_reference_number: generate(:teacher_reference_number)},
email_address: generate(:email_address),
bank_sort_code: "112233",
bank_account_number: "95928482",
@@ -262,11 +262,11 @@
end
describe "method delegations" do
- described_class::PERSONAL_DETAILS_ATTRIBUTES_PERMITTING_DISCREPANCIES.each do |method|
+ described_class::PERSONAL_CLAIM_DETAILS_ATTRIBUTES_PERMITTING_DISCREPANCIES.each do |method|
it { is_expected.to delegate_method(method).to(:claim_for_personal_details) }
end
- described_class::PERSONAL_DETAILS_ATTRIBUTES_FORBIDDING_DISCREPANCIES.each do |method|
+ described_class::PERSONAL_CLAIM_DETAILS_ATTRIBUTES_FORBIDDING_DISCREPANCIES.each do |method|
it { is_expected.to delegate_method(method).to(:claim_for_personal_details) }
end
end
diff --git a/spec/models/payroll/payment_csv_row_spec.rb b/spec/models/payroll/payment_csv_row_spec.rb
index 851514f27b..e306b8356e 100644
--- a/spec/models/payroll/payment_csv_row_spec.rb
+++ b/spec/models/payroll/payment_csv_row_spec.rb
@@ -16,7 +16,7 @@
let(:personal_details_for_student_loans_and_early_career_payments_claim) do
{
national_insurance_number: generate(:national_insurance_number),
- teacher_reference_number: generate(:teacher_reference_number),
+ eligibility_attributes: {teacher_reference_number: generate(:teacher_reference_number)},
payroll_gender: :female,
date_of_birth: Date.new(1980, 12, 1),
student_loan_plan: StudentLoan::PLAN_2,
@@ -105,7 +105,7 @@
let(:personal_details_for_ecp_claim_1) do
{
national_insurance_number: generate(:national_insurance_number),
- teacher_reference_number: generate(:teacher_reference_number),
+ eligibility_attributes: {teacher_reference_number: generate(:teacher_reference_number)},
payroll_gender: :male,
date_of_birth: Date.new(1988, 3, 21),
student_loan_plan: StudentLoan::PLAN_1_AND_3,
@@ -177,7 +177,7 @@
let(:personal_details_for_ecp_claim_2) do
{
national_insurance_number: generate(:national_insurance_number),
- teacher_reference_number: generate(:teacher_reference_number),
+ eligibility_attributes: {teacher_reference_number: generate(:teacher_reference_number)},
payroll_gender: :female,
date_of_birth: Date.new(1994, 6, 30),
student_loan_plan: StudentLoan::PLAN_1,
diff --git a/spec/models/payroll_run_spec.rb b/spec/models/payroll_run_spec.rb
index a353d9c842..ac6d7dd487 100644
--- a/spec/models/payroll_run_spec.rb
+++ b/spec/models/payroll_run_spec.rb
@@ -54,8 +54,8 @@
describe "#total_award_amount" do
it "returns the sum of the award amounts of its claims" do
- payment_1 = build(:payment, claims: [build(:claim, :approved, eligibility: build(:student_loans_eligibility, :eligible, student_loan_repayment_amount: 1500))])
- payment_2 = build(:payment, claims: [build(:claim, :approved, eligibility: build(:student_loans_eligibility, :eligible, student_loan_repayment_amount: 2000))])
+ payment_1 = build(:payment, claims: [build(:claim, :approved, eligibility_attributes: {student_loan_repayment_amount: 1500})])
+ payment_2 = build(:payment, claims: [build(:claim, :approved, eligibility_attributes: {student_loan_repayment_amount: 2000})])
payroll_run = PayrollRun.create!(created_by: user, payments: [payment_1, payment_2])
@@ -66,13 +66,13 @@
describe "#number_of_claims_for_policy" do
it "returns the correct number of claims under each policy" do
payment_1 = build(:payment, claims: [
- build(:claim, :approved, eligibility: build(:student_loans_eligibility, :eligible, student_loan_repayment_amount: 1500))
+ build(:claim, :approved, eligibility_attributes: {student_loan_repayment_amount: 1500})
])
payment_2 = build(:payment, claims: [
- build(:claim, :approved, policy: Policies::EarlyCareerPayments, eligibility: build(:early_career_payments_eligibility, :eligible))
+ build(:claim, :approved, policy: Policies::EarlyCareerPayments)
])
payment_3 = build(:payment, claims: [
- build(:claim, :approved, policy: Policies::LevellingUpPremiumPayments, eligibility: build(:levelling_up_premium_payments_eligibility, :eligible))
+ build(:claim, :approved, policy: Policies::LevellingUpPremiumPayments)
])
payroll_run = PayrollRun.create!(created_by: user, payments: [payment_1, payment_2, payment_3])
@@ -86,20 +86,20 @@
describe "#total_claim_amount_for_policy" do
it "returns the correct total amount claimed under each policy" do
payment_1 = build(:payment, claims: [
- build(:claim, :approved, eligibility: build(:student_loans_eligibility, :eligible, student_loan_repayment_amount: 1500))
+ build(:claim, :approved, policy: Policies::StudentLoans, eligibility_attributes: {student_loan_repayment_amount: 1500})
])
payment_2 = build(:payment, claims: [
- build(:claim, :approved, policy: Policies::EarlyCareerPayments, eligibility: build(:early_career_payments_eligibility, :eligible))
+ build(:claim, :approved, policy: Policies::EarlyCareerPayments)
])
payment_3 = build(:payment, claims: [
- build(:claim, :approved, policy: Policies::EarlyCareerPayments, eligibility: build(:early_career_payments_eligibility, :eligible))
+ build(:claim, :approved, policy: Policies::EarlyCareerPayments)
])
payment_4 = build(:payment, claims: [
- build(:claim, :approved, eligibility: build(:student_loans_eligibility, :eligible, student_loan_repayment_amount: 1000))
+ build(:claim, :approved, eligibility_attributes: {student_loan_repayment_amount: 1000})
])
payment_5 = build(:payment, claims: [
- build(:claim, :approved, policy: Policies::LevellingUpPremiumPayments, teacher_reference_number: "1234567", bank_sort_code: "123456", bank_account_number: "12345678", eligibility: build(:levelling_up_premium_payments_eligibility, :eligible)),
- build(:claim, :approved, teacher_reference_number: "1234567", bank_sort_code: "123456", bank_account_number: "12345678", eligibility: build(:student_loans_eligibility, :eligible, student_loan_repayment_amount: 1000))
+ build(:claim, :approved, policy: Policies::LevellingUpPremiumPayments, bank_sort_code: "123456", bank_account_number: "12345678", eligibility_attributes: {teacher_reference_number: "1234567"}),
+ build(:claim, :approved, bank_sort_code: "123456", bank_account_number: "12345678", eligibility_attributes: {student_loan_repayment_amount: 1000, teacher_reference_number: "1234567"})
])
payroll_run = PayrollRun.create!(created_by: user, payments: [payment_1, payment_2, payment_3, payment_4, payment_5])
@@ -126,7 +126,7 @@
let(:personal_details) do
{
national_insurance_number: generate(:national_insurance_number),
- teacher_reference_number: generate(:teacher_reference_number),
+ eligibility_attributes: {teacher_reference_number: generate(:teacher_reference_number)},
email_address: generate(:email_address),
bank_sort_code: "112233",
bank_account_number: "95928482",
diff --git a/spec/models/policies_spec.rb b/spec/models/policies_spec.rb
index 89d90aff26..9384573a53 100644
--- a/spec/models/policies_spec.rb
+++ b/spec/models/policies_spec.rb
@@ -13,8 +13,8 @@
describe "::AMENDABLE_ELIGIBILITY_ATTRIBUTES" do
it do
- expect(described_class::AMENDABLE_ELIGIBILITY_ATTRIBUTES).to eq([
- :student_loan_repayment_amount, :award_amount, :award_amount
+ expect(described_class::AMENDABLE_ELIGIBILITY_ATTRIBUTES.sort).to eq([
+ :award_amount, :student_loan_repayment_amount, :teacher_reference_number
])
end
end
diff --git a/spec/models/student_loans/eligibility_spec.rb b/spec/models/student_loans/eligibility_spec.rb
index c452cbd78a..9dc19a469b 100644
--- a/spec/models/student_loans/eligibility_spec.rb
+++ b/spec/models/student_loans/eligibility_spec.rb
@@ -50,8 +50,8 @@
end
it "validates that the loan repayment less than £5000 when amending a claim" do
- expect(described_class.new(student_loan_repayment_amount: "5001")).not_to be_valid(:amendment)
- expect(described_class.new(student_loan_repayment_amount: "1200")).to be_valid(:amendment)
+ expect(described_class.new(teacher_reference_number: "1234567", student_loan_repayment_amount: "5001")).not_to be_valid(:amendment)
+ expect(described_class.new(teacher_reference_number: "1234567", student_loan_repayment_amount: "1200")).to be_valid(:amendment)
end
end
diff --git a/spec/models/teachers_pensions_service_spec.rb b/spec/models/teachers_pensions_service_spec.rb
index ca55cdf177..52621bae15 100644
--- a/spec/models/teachers_pensions_service_spec.rb
+++ b/spec/models/teachers_pensions_service_spec.rb
@@ -8,7 +8,7 @@
let(:school) { create(:school, local_authority:, establishment_number:) }
let(:la_urn) { local_authority.code }
let(:school_urn) { school.establishment_number }
- let(:teacher_reference_number) { claim.teacher_reference_number }
+ let(:teacher_reference_number) { claim.eligibility.teacher_reference_number }
let(:start_date) { end_date - 1.week }
describe ".recent_tps_school" do
@@ -63,7 +63,7 @@
let!(:ineligible_school) { create(:school, :student_loans_ineligible) }
let!(:ineligible_school2) { create(:school, :student_loans_ineligible) }
let(:trn) { "1234567" }
- let(:claim) { create(:claim, teacher_reference_number: trn) }
+ let(:claim) { create(:claim, eligibility_attributes: {teacher_reference_number: trn}) }
context "previous financial year has eligible school and ineligible school" do
it "returns most recent eligible school" do
diff --git a/spec/requests/admin_amendments_spec.rb b/spec/requests/admin_amendments_spec.rb
index 6b4f07cf12..ac416edf14 100644
--- a/spec/requests/admin_amendments_spec.rb
+++ b/spec/requests/admin_amendments_spec.rb
@@ -1,13 +1,13 @@
require "rails_helper"
RSpec.describe "Admin claim amendments" do
- let(:claim) { create(:claim, :submitted, teacher_reference_number: "1234567", bank_sort_code: "010203", date_of_birth: 25.years.ago.to_date) }
+ let(:claim) { create(:claim, :submitted, eligibility_attributes: {teacher_reference_number: "1234567"}, bank_sort_code: "010203", date_of_birth: 25.years.ago.to_date) }
context "when signed in as a service operator" do
before { @signed_in_user = sign_in_as_service_operator }
describe "admin/amendments#index" do
- let(:claim) { create(:claim, :submitted, teacher_reference_number: "1234567") }
+ let(:claim) { create(:claim, :submitted, eligibility_attributes: {teacher_reference_number: "1234567"}) }
let!(:amendment) { create(:amendment, claim: claim, notes: "Made a change", claim_changes: {"teacher_reference_number" => ["7654321", "1234567"]}) }
it "list the amendments on a claim" do
@@ -23,7 +23,7 @@
old_date_of_birth = claim.date_of_birth
new_date_of_birth = 30.years.ago.to_date
expect {
- post admin_claim_amendments_url(claim, amendment: {claim: {teacher_reference_number: "7654321", bank_sort_code: "111213", "date_of_birth(3i)": new_date_of_birth.day, "date_of_birth(2i)": new_date_of_birth.month, "date_of_birth(1i)": new_date_of_birth.year},
+ post admin_claim_amendments_url(claim, amendment: {claim: {eligibility_attributes: {teacher_reference_number: "7654321"}, bank_sort_code: "111213", "date_of_birth(3i)": new_date_of_birth.day, "date_of_birth(2i)": new_date_of_birth.month, "date_of_birth(1i)": new_date_of_birth.year},
notes: "Claimant made a typo"})
}.to change { claim.reload.amendments.size }.by(1)
@@ -39,7 +39,7 @@
expect(amendment.notes).to eq("Claimant made a typo")
expect(amendment.created_by).to eq(@signed_in_user)
- expect(claim.teacher_reference_number).to eq("7654321")
+ expect(claim.eligibility.teacher_reference_number).to eq("7654321")
expect(claim.bank_sort_code).to eq("111213")
expect(claim.date_of_birth).to eq(new_date_of_birth)
end
@@ -66,9 +66,9 @@
it "displays a validation error and does not update the claim or create an amendment when invalid values are entered" do
expect {
- post admin_claim_amendments_url(claim, amendment: {claim: {teacher_reference_number: "654321", bank_account_number: ""},
+ post admin_claim_amendments_url(claim, amendment: {claim: {eligibility_attributes: {teacher_reference_number: "654321"}, bank_account_number: ""},
notes: "Claimant made a typo"})
- }.not_to change { [claim.reload.teacher_reference_number, claim.amendments.size] }
+ }.not_to change { [claim.eligibility.reload.teacher_reference_number, claim.amendments.size] }
expect(response).to have_http_status(:ok)
@@ -78,9 +78,9 @@
it "displays an error message and does not create an amendment when none of the claim’s values are changed" do
expect {
- post admin_claim_amendments_url(claim, amendment: {claim: {teacher_reference_number: claim.teacher_reference_number},
+ post admin_claim_amendments_url(claim, amendment: {claim: {eligibility_attributes: {teacher_reference_number: claim.eligibility.teacher_reference_number}},
notes: "Claimant made a typo"})
- }.not_to change { [claim.reload.teacher_reference_number, claim.amendments.size] }
+ }.not_to change { [claim.eligibility.reload.teacher_reference_number, claim.amendments.size] }
expect(response).to have_http_status(:ok)
@@ -105,7 +105,7 @@
let(:claim) { create(:claim, :approved, payments: [payment]) }
it "shows an error" do
- post admin_claim_amendments_url(claim, amendment: {claim: {teacher_reference_number: claim.teacher_reference_number},
+ post admin_claim_amendments_url(claim, amendment: {claim: {eligibility_attributes: {teacher_reference_number: claim.eligibility.teacher_reference_number}},
notes: "Claimant made a typo"})
expect(response.body).to include("This claim cannot be amended.")
end
@@ -130,8 +130,8 @@
describe "admin_amendments#create" do
it "returns a unauthorized response and does not create an amendment or change the claim" do
expect {
- post admin_claim_amendments_url(claim, amendment: {claim: {teacher_reference_number: "7654321"}})
- }.not_to change { [claim.reload.teacher_reference_number, claim.amendments.size] }
+ post admin_claim_amendments_url(claim, amendment: {claim: {eligibility_attributes: {teacher_reference_number: "7654321"}}})
+ }.not_to change { [claim.eligibility.reload.teacher_reference_number, claim.amendments.size] }
expect(response).to have_http_status(:unauthorized)
end
diff --git a/spec/requests/admin_claims_spec.rb b/spec/requests/admin_claims_spec.rb
index ec6cb4b437..f7c6fce3de 100644
--- a/spec/requests/admin_claims_spec.rb
+++ b/spec/requests/admin_claims_spec.rb
@@ -110,7 +110,7 @@
end
context "when another claim has matching attributes" do
- let!(:claim_with_matching_attributes) { create(:claim, :submitted, teacher_reference_number: claim.teacher_reference_number, policy: policy) }
+ let!(:claim_with_matching_attributes) { create(:claim, :submitted, eligibility_attributes: {teacher_reference_number: claim.eligibility.teacher_reference_number}, policy: policy) }
it "returns the claim and the duplicate" do
get admin_claim_path(claim)
diff --git a/spec/requests/admin_decisions_spec.rb b/spec/requests/admin_decisions_spec.rb
index 50a45e594e..73d56b292e 100644
--- a/spec/requests/admin_decisions_spec.rb
+++ b/spec/requests/admin_decisions_spec.rb
@@ -219,7 +219,7 @@
let(:personal_details) do
{
national_insurance_number: generate(:national_insurance_number),
- teacher_reference_number: generate(:teacher_reference_number),
+ eligibility_attributes: {teacher_reference_number: generate(:teacher_reference_number)},
date_of_birth: 30.years.ago.to_date,
student_loan_plan: StudentLoan::PLAN_1,
email_address: "email@example.com",
diff --git a/spec/requests/admin_payroll_runs_spec.rb b/spec/requests/admin_payroll_runs_spec.rb
index 7f2dd0f036..ba603a0af4 100644
--- a/spec/requests/admin_payroll_runs_spec.rb
+++ b/spec/requests/admin_payroll_runs_spec.rb
@@ -17,9 +17,9 @@
it "limits the number of claims entering payroll when exceeding the maximum allowed" do
stubbed_max_payments = stub_const("PayrollRun::MAX_MONTHLY_PAYMENTS", 2)
- create(:claim, :approved, eligibility: create(:student_loans_eligibility, student_loan_repayment_amount: 100), submitted_at: 3.days.ago)
- create(:claim, :approved, eligibility: create(:student_loans_eligibility, student_loan_repayment_amount: 50), submitted_at: 1.days.ago)
- create(:claim, :approved, eligibility: create(:student_loans_eligibility, student_loan_repayment_amount: 10), submitted_at: 2.days.ago)
+ create(:claim, :approved, eligibility_attributes: {student_loan_repayment_amount: 100}, submitted_at: 3.days.ago)
+ create(:claim, :approved, eligibility_attributes: {student_loan_repayment_amount: 50}, submitted_at: 1.days.ago)
+ create(:claim, :approved, eligibility_attributes: {student_loan_repayment_amount: 10}, submitted_at: 2.days.ago)
get new_admin_payroll_run_path
diff --git a/spec/requests/admin_tps_data_upload_spec.rb b/spec/requests/admin_tps_data_upload_spec.rb
index eb92da3f7f..56d49ded09 100644
--- a/spec/requests/admin_tps_data_upload_spec.rb
+++ b/spec/requests/admin_tps_data_upload_spec.rb
@@ -76,10 +76,10 @@ def upload_tps_data_csm_file(file)
:claim,
:submitted,
policy: Policies::EarlyCareerPayments,
- teacher_reference_number: 1000106,
submitted_at: Date.new(2022, 7, 15),
academic_year: AcademicYear::Type.new.serialize(AcademicYear.new(2021)),
eligibility_attributes: {
+ teacher_reference_number: 1000106,
current_school: current_school
}
)
@@ -90,9 +90,9 @@ def upload_tps_data_csm_file(file)
:claim,
:submitted,
policy: Policies::EarlyCareerPayments,
- teacher_reference_number: 1000107,
submitted_at: Date.new(2022, 7, 15),
- academic_year: AcademicYear::Type.new.serialize(AcademicYear.new(2021))
+ academic_year: AcademicYear::Type.new.serialize(AcademicYear.new(2021)),
+ eligibility_attributes: {teacher_reference_number: 1000107}
)
end
@@ -101,9 +101,9 @@ def upload_tps_data_csm_file(file)
:claim,
:submitted,
policy: Policies::EarlyCareerPayments,
- teacher_reference_number: 1000108,
submitted_at: Date.new(2022, 7, 15),
- academic_year: AcademicYear::Type.new.serialize(AcademicYear.new(2021))
+ academic_year: AcademicYear::Type.new.serialize(AcademicYear.new(2021)),
+ eligibility_attributes: {teacher_reference_number: 1000108}
)
end
@@ -143,7 +143,7 @@ def upload_tps_data_csm_file(file)
it "runs the employment task again for NO MATCH claims" do
csv = <<~CSV
Teacher reference number,NINO,Start Date,End Date,LA URN,School URN,Employer ID
- #{claim_no_data.teacher_reference_number},ZX043155C,01/07/2022,30/09/2022,#{claim_no_data.school.local_authority.code},#{claim_no_data.school.establishment_number},1122
+ #{claim_no_data.eligibility.teacher_reference_number},ZX043155C,01/07/2022,30/09/2022,#{claim_no_data.school.local_authority.code},#{claim_no_data.school.establishment_number},1122
CSV
file = Rack::Test::UploadedFile.new(StringIO.new(csv), "text/csv", original_filename: "tps_data.csv")
@@ -184,10 +184,10 @@ def upload_tps_data_csm_file(file)
:claim,
:submitted,
policy: Policies::StudentLoans,
- teacher_reference_number: 1000106,
submitted_at: Date.new(2022, 7, 15),
academic_year: AcademicYear::Type.new.serialize(AcademicYear.new(2021)),
eligibility_attributes: {
+ teacher_reference_number: 1000106,
current_school: current_school,
claim_school: claim_school
}
@@ -199,9 +199,9 @@ def upload_tps_data_csm_file(file)
:claim,
:submitted,
policy: Policies::StudentLoans,
- teacher_reference_number: 1000107,
submitted_at: Date.new(2022, 7, 15),
- academic_year: AcademicYear::Type.new.serialize(AcademicYear.new(2021))
+ academic_year: AcademicYear::Type.new.serialize(AcademicYear.new(2021)),
+ eligibility_attributes: {teacher_reference_number: 1000107}
)
end
diff --git a/spec/support/admin_edit_claim_feature_shared_examples.rb b/spec/support/admin_edit_claim_feature_shared_examples.rb
index 6494e83ed9..555602db1d 100644
--- a/spec/support/admin_edit_claim_feature_shared_examples.rb
+++ b/spec/support/admin_edit_claim_feature_shared_examples.rb
@@ -30,7 +30,7 @@
end
context "non-claim attribute" do
- let(:old_value) { claim.teacher_reference_number }
+ let(:old_value) { claim.eligibility.teacher_reference_number }
let(:new_value) { old_value.next }
let(:reason) { "Fix typo" }
diff --git a/spec/support/admin_view_claim_feature_shared_examples.rb b/spec/support/admin_view_claim_feature_shared_examples.rb
index 6f02411e14..6a94d47da8 100644
--- a/spec/support/admin_view_claim_feature_shared_examples.rb
+++ b/spec/support/admin_view_claim_feature_shared_examples.rb
@@ -34,13 +34,12 @@
}
let!(:similar_claim) {
- eligibility = create(:"#{policy.to_s.underscore}_eligibility", :eligible)
+ eligibility = create(:"#{policy.to_s.underscore}_eligibility", :eligible, teacher_reference_number: multiple_claim.eligibility.teacher_reference_number)
create(
:claim,
:submitted,
policy: policy,
- eligibility: eligibility,
- teacher_reference_number: multiple_claim.teacher_reference_number
+ eligibility: eligibility
)
}
diff --git a/spec/support/fixture_helpers.rb b/spec/support/fixture_helpers.rb
index f8213c56af..3203f4c8ce 100644
--- a/spec/support/fixture_helpers.rb
+++ b/spec/support/fixture_helpers.rb
@@ -13,7 +13,7 @@ def claim_from_example_dqt_report(trait)
create(:claim, :submitted,
first_name: "FRED",
surname: "ELIGIBLE",
- teacher_reference_number: "1234567",
+ eligibility_attributes: {teacher_reference_number: "1234567"},
reference: "AB123456",
date_of_birth: Date.new(1990, 8, 23),
national_insurance_number: "QQ123456C")
@@ -23,7 +23,7 @@ def claim_from_example_dqt_report(trait)
create(:claim, :submitted,
first_name: "Dwayne",
surname: "Hecos",
- teacher_reference_number: "9876543",
+ eligibility_attributes: {teacher_reference_number: "9876543"},
reference: "ZY987654",
date_of_birth: Date.new(1991, 1, 8),
national_insurance_number: "QQ123456C")
@@ -33,7 +33,7 @@ def claim_from_example_dqt_report(trait)
create(:claim, :submitted,
first_name: "Jo",
surname: "Eligible",
- teacher_reference_number: "8901231",
+ eligibility_attributes: {teacher_reference_number: "8901231"},
reference: "RR123456",
date_of_birth: Date.new(1899, 1, 1),
national_insurance_number: "QQ123456C")
@@ -43,33 +43,33 @@ def claim_from_example_dqt_report(trait)
create(:claim, :submitted,
first_name: "Sarah",
surname: "Eligible",
- teacher_reference_number: "8981212",
+ eligibility_attributes: {teacher_reference_number: "8981212"},
reference: "DD123456",
date_of_birth: Date.new(1980, 4, 10),
national_insurance_number: "QQ123456C")
when :claim_without_dqt_record
# Submitted claim that has no DQT associated with it
- create(:claim, :submitted, teacher_reference_number: "3456789", reference: "XX123456")
+ create(:claim, :submitted, eligibility_attributes: {teacher_reference_number: "3456789"}, reference: "XX123456")
when :claim_with_ineligible_dqt_record
# Submitted claim with matching data in DQT that is considered ineligible
create(:claim, :submitted,
- teacher_reference_number: "6758493",
+ eligibility_attributes: {teacher_reference_number: "6758493"},
reference: "CD123456",
date_of_birth: Date.new(1979, 4, 21))
when :claim_with_decision
# Eligible claim with matching data that already has a decision
create(:claim, :approved,
- teacher_reference_number: "5554433",
+ eligibility_attributes: {teacher_reference_number: "5554433"},
reference: "EF123456",
date_of_birth: Date.new(1985, 5, 15))
when :claim_with_qualification_task
# Eligible claim with matching data that already has a qualification task
create(:claim, :submitted,
- teacher_reference_number: "6060606",
+ eligibility_attributes: {teacher_reference_number: "6060606"},
reference: "GH123456",
date_of_birth: Date.new(1980, 10, 4),
tasks: [build(:task, name: "qualifications")])