Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RST-7092 - No partner details where no Applicant NI number #2004

Merged
merged 3 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def create
private

def path_to_next_page
if application.applicant.married? && ucd_changes_applies?
if application.applicant.married? && ucd_changes_applies? && application.applicant.ni_number.present?
application_partner_informations_path(application)
else
application_details_path(application)
Expand Down
4 changes: 2 additions & 2 deletions app/models/applicant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Applicant < ActiveRecord::Base
include ApplicantCheckable

before_validation :format_ni_number, :format_ho_number
before_validation :remove_partner_info, if: :married_changed?
before_validation :remove_partner_info

validates :ni_number, format: {
with: /\A(?!BG|GB|NK|KN|TN|NT|ZZ)[ABCEGHJ-PRSTW-Z][ABCEGHJ-NPRSTW-Z]\d{6}[A-D]\z/
Expand Down Expand Up @@ -35,7 +35,7 @@ def under_age?
private

def remove_partner_info
return if married == true
return if married == true && ni_number.present?
self.partner_date_of_birth = nil
self.partner_first_name = nil
self.partner_last_name = nil
Expand Down
6 changes: 3 additions & 3 deletions app/views/online_applications/_post_ucd_show.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,17 @@ dl.govuk-summary-list
dd.govuk-summary-list__value =@online_application_view.status

- if @online_application_view.married
- if @online_application_view&.partner_full_name.present?
- if @online_application_view&.partner_full_name.present? && @online_application_view.ni_number.present?
.govuk-summary-list__row
dt.govuk-summary-list__key =t('summary.partner_full_name')
dd.govuk-summary-list__value =@online_application_view.partner_full_name

- if @online_application_view.partner_date_of_birth.present?
- if @online_application_view.partner_date_of_birth.present? && @online_application_view.ni_number.present?
.govuk-summary-list__row
dt.govuk-summary-list__key =t('summary.partner_date_of_birth')
dd.govuk-summary-list__value =@online_application_view.partner_date_of_birth

- if @online_application_view.partner_ni_number.present?
- if @online_application_view.partner_ni_number.present? && @online_application_view.ni_number.present?
.govuk-summary-list__row
dt.govuk-summary-list__key =t('summary.partner_ni_number')
dd.govuk-summary-list__value =@online_application_view.partner_ni_number
Expand Down
7 changes: 3 additions & 4 deletions app/views/shared/_application_summary.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,8 @@ dl.govuk-summary-list
span.govuk-visually-hidden=t('summary.status')



- if @applicant.married
- if @applicant&.partner_full_name.present?
- if @applicant&.partner_full_name.present? && @applicant.ni_number.present?
.govuk-summary-list__row
dt.govuk-summary-list__key =t('summary.partner_full_name')
dd.govuk-summary-list__value =@applicant.partner_full_name
Expand All @@ -104,7 +103,7 @@ dl.govuk-summary-list
span.govuk-visually-hidden=t('summary.partner_full_name')


- if @applicant.partner_date_of_birth.present?
- if @applicant.partner_date_of_birth.present? && @applicant.ni_number.present?
.govuk-summary-list__row
dt.govuk-summary-list__key =t('summary.partner_date_of_birth')
dd.govuk-summary-list__value =@applicant.partner_date_of_birth
Expand All @@ -114,7 +113,7 @@ dl.govuk-summary-list
= 'Change'
span.govuk-visually-hidden=t('summary.partner_date_of_birth')

- if @applicant.partner_ni_number.present?
- if @applicant.partner_ni_number.present? && @applicant.ni_number.present?
.govuk-summary-list__row
dt.govuk-summary-list__key =t('summary.partner_ni_number')
dd.govuk-summary-list__value =@applicant.partner_ni_number
Expand Down
2 changes: 1 addition & 1 deletion charts/help-with-fees-staffapp/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ appVersion: '1.0'
description: A Helm chart for hwf-staffapp App
name: help-with-fees-staffapp
home: https://github.com/hmcts/hwf-staffapp
version: 0.0.73
version: 0.0.74
dependencies:
- name: base
version: 1.3.0
Expand Down
36 changes: 34 additions & 2 deletions spec/models/forms/application/partner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
end

describe 'when Applicant object is passed in' do
let(:applicant) { build(:applicant) }
let(:applicant) { build(:applicant, :married) }
let(:form) { described_class.new(applicant) }

params_list.each do |attr_name|
Expand Down Expand Up @@ -220,7 +220,7 @@
end

let(:applicant) { application.applicant }
let(:application) { create(:application, :applicant_full) }
let(:application) { create(:application, :applicant_full, married: true) }

context 'when the attributes are correct' do
let(:dob) { '01/01/1980' }
Expand Down Expand Up @@ -270,5 +270,37 @@
is_expected.to be false
end
end

context 'when married is true but no applicant NI number' do
let(:application) { create(:application, :applicant_full, married: true, ni_number: nil) }
let(:params) { { partner_first_name: 'John', partner_last_name: 'Doe', partner_ni_number: 'AB123456C' } }

before do
form_save
applicant.reload
end

it 'clears partner details' do
expect(applicant.partner_first_name).to be_nil
expect(applicant.partner_last_name).to be_nil
expect(applicant.partner_ni_number).to be_nil
end
end

context 'when married is false but applicant provides an NI number' do
let(:application) { create(:application, :applicant_full, married: false, ni_number: 'AB123456C') }
let(:params) { { partner_first_name: 'John', partner_last_name: 'Doe', partner_ni_number: 'AB123456C' } }

before do
form_save
applicant.reload
end

it 'clears partner details' do
expect(applicant.partner_first_name).to be_nil
expect(applicant.partner_last_name).to be_nil
expect(applicant.partner_ni_number).to be_nil
end
end
end
end
9 changes: 6 additions & 3 deletions spec/models/views/reports/hmrc_ocmc_data_export_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
Timecop.freeze(date_from + 5.days) { application5 }
Timecop.freeze(date_from + 36.days) { application6 }
Timecop.freeze(date_from + 6.days) { application7 }
application1.applicant.update(partner_ni_number: 'SN789654C')
application3.applicant.update(partner_ni_number: 'SN789654C', partner_last_name: 'Jones')
application4.applicant.update(partner_ni_number: '', partner_last_name: 'Jones')
application1.applicant.update(partner_ni_number: 'SN789654C', married: true, ni_number: 'SN789654C')
application3.applicant.update(partner_ni_number: 'SN789654C', partner_last_name: 'Jones', married: true, ni_number: 'SN789654C')
application4.applicant.update(partner_ni_number: '', partner_last_name: 'Jones', married: true, ni_number: 'SN789654C')
end

it 'return 5 rows csv data' do
Expand Down Expand Up @@ -210,6 +210,7 @@
context 'plain application' do
it {
application1.update(decision: 'full')
application1.applicant.update(married: false)
reference = application1.reference
data_row = data.find { |row| row.split(',')[1] == reference }
expect(data_row).to include('no,full,,,0.0')
Expand All @@ -219,6 +220,7 @@
context 'evidence check' do
it {
application1.update(decision: 'full')
application1.applicant.update(married: false)
evidence_check

reference = application1.reference
Expand All @@ -230,6 +232,7 @@
context 'part payment check' do
it {
application1.update(decision: 'full')
application1.applicant.update(married: false)
evidence_check
part_payment

Expand Down
2 changes: 1 addition & 1 deletion spec/models/views/reports/raw_data_export_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@

expect(export).to include(row)
expect(export).to include("#{office},#{full_no_ec.reference}")
expect(export).to include("JK123455B,,#{dob},#{date_received},#{decision_date.to_fs},,,litigation_friend,true,false,post_ucd")
expect(export).to include("JK123455B,,#{dob},#{date_received},#{decision_date.to_fs},,,litigation_friend,false,false,post_ucd")
end
end

Expand Down