From 3af5ee89636fd47c09085b2f2dcaaccae38973d6 Mon Sep 17 00:00:00 2001 From: Richard Lynch Date: Thu, 7 Nov 2024 10:53:32 +0000 Subject: [PATCH] Fix assigning SLC plan 1 When a claim without a student loan plan is amended the student loan plan was being set to Plan 1, the default option in the list. This commit includes a blank option so unrelated amendments on a claims without a plan don't send up the Plan 1 value. --- app/models/claim.rb | 1 - app/views/admin/amendments/new.html.erb | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/claim.rb b/app/models/claim.rb index 2326c216bd..72240ea760 100644 --- a/app/models/claim.rb +++ b/app/models/claim.rb @@ -152,7 +152,6 @@ class Claim < ApplicationRecord validates :has_student_loan, on: [:"student-loan"], inclusion: {in: [true, false]}, allow_nil: true validates :student_loan_plan, inclusion: {in: STUDENT_LOAN_PLAN_OPTIONS}, allow_nil: true - validates :student_loan_plan, on: [:amendment], presence: {message: "Enter a valid student loan plan"} validates :bank_sort_code, on: [:amendment], presence: {message: "Enter a sort code"} validates :bank_account_number, on: [:amendment], presence: {message: "Enter an account number"} diff --git a/app/views/admin/amendments/new.html.erb b/app/views/admin/amendments/new.html.erb index 416d8b8dc0..06b601af38 100644 --- a/app/views/admin/amendments/new.html.erb +++ b/app/views/admin/amendments/new.html.erb @@ -95,7 +95,12 @@
- <%= claim_form.select :student_loan_plan, Claim::STUDENT_LOAN_PLAN_OPTIONS.map { |option| [option.humanize, option] }, {}, { class: "govuk-select" } %> + <%= claim_form.select( + :student_loan_plan, + Claim::STUDENT_LOAN_PLAN_OPTIONS.map { |option| [option.humanize, option] }, + { include_blank: true }, + { class: "govuk-select" } + ) %>