Skip to content

Commit

Permalink
Merge pull request #3344 from DFE-Digital/CAPT-1885-normalise-ni-number
Browse files Browse the repository at this point in the history
[CAPT-1885] normalise NI number before saving in answers
  • Loading branch information
alkesh authored Oct 25, 2024
2 parents 9c34699 + 999fb40 commit ad1daeb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/forms/personal_details_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def save
middle_name:,
surname:,
date_of_birth:,
national_insurance_number:
national_insurance_number: normalised_ni_number
)

reset_dependent_answers_attributes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
fill_in "Day", with: "28"
fill_in "Month", with: "2"
fill_in "Year", with: "1988"
fill_in "National Insurance number", with: "PX321499A"
fill_in "National Insurance number", with: "PX321499A " # deliberate trailing space
click_on "Continue"

expect(page).to have_content("What is your home address?")
Expand Down
25 changes: 22 additions & 3 deletions spec/forms/personal_details_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,10 @@
end

describe "#save" do
context "with valid params" do
let(:logged_in_with_tid) { nil }
let(:teacher_id_user_info) { {} }
let(:logged_in_with_tid) { nil }
let(:teacher_id_user_info) { {} }

context "with valid params" do
let(:params) do
{
first_name: "Dr",
Expand Down Expand Up @@ -379,6 +379,25 @@
expect(answers.student_loan_plan).to be nil
end
end

context "with a national insurance number with spaces" do
let(:params) do
{
first_name: "Dr",
middle_name: "Bob",
surname: "Loblaw",
day: 1,
month: 1,
year: 1990,
national_insurance_number: "QQ 123456 C "
}
end

it "strips spaces" do
form.save
expect(journey_session.answers.national_insurance_number).to eq "QQ123456C"
end
end
end
end

Expand Down

0 comments on commit ad1daeb

Please sign in to comment.