Skip to content

Commit

Permalink
Fix assigning SLC plan 1
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rjlynch committed Nov 8, 2024
1 parent 767c3d1 commit 7b5d867
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 0 additions & 1 deletion app/models/claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand Down
7 changes: 6 additions & 1 deletion app/views/admin/amendments/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,12 @@
</div>
<div class="govuk-grid-column-two-thirds">
<div class="govuk-form-group">
<%= 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" }
) %>
</div>
</div>
</div>
Expand Down
1 change: 0 additions & 1 deletion spec/models/claim_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
expect(claim).not_to be_valid(:amendment)
expect(claim.errors.map(&:message)).to contain_exactly(
"Enter your teacher reference number",
"Enter a valid student loan plan",
"Enter a sort code",
"Enter an account number"
)
Expand Down

0 comments on commit 7b5d867

Please sign in to comment.