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

API-39899-update-zip-first-five-validations-for-coa #18341

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
9acc330
API-39899-update-zip-first-five-validations-for-coa
rockwellwindsor-va Sep 5, 2024
c183e9a
Merge branch 'master' into API-39899-update-zip-first-five-validation…
rockwellwindsor-va Sep 6, 2024
9121297
Merges in master fixes conflicts
rockwellwindsor-va Sep 9, 2024
bb4a0ff
Reverts Gemfile.lock commit after merge conflict
rockwellwindsor-va Sep 9, 2024
10ce9d3
Merge branch 'master' into API-39899-update-zip-first-five-validation…
rockwellwindsor-va Sep 11, 2024
5c7d84a
Rolls back prohibiting zipFirstfive if country not USA
rockwellwindsor-va Sep 11, 2024
c175cde
Merges in master branch and resolves conflicts
rockwellwindsor-va Sep 11, 2024
e38c3a6
Reverts Gemfile.lock update from merge conflict
rockwellwindsor-va Sep 11, 2024
a421694
Cleans up tests and adds one test for internationalPostalCode
rockwellwindsor-va Sep 11, 2024
d3dd3e6
Cleans up more merge conflict artifacts
rockwellwindsor-va Sep 11, 2024
2397f7e
Fixes conditional
rockwellwindsor-va Sep 11, 2024
4632858
Rubocop fixes
rockwellwindsor-va Sep 11, 2024
b4953b8
Gets correct test added for internation postal code after merge conflict
rockwellwindsor-va Sep 11, 2024
67a312c
Merge branch 'master' into API-39899-update-zip-first-five-validation…
rockwellwindsor-va Sep 16, 2024
2eaf7e7
Merge branch 'master' into API-39899-update-zip-first-five-validation…
rockwellwindsor-va Sep 16, 2024
9482ce5
Merge branch 'master' into API-39899-update-zip-first-five-validation…
rockwellwindsor-va Sep 16, 2024
da5ee93
Merge branch 'master' into API-39899-update-zip-first-five-validation…
rockwellwindsor-va Sep 17, 2024
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 @@ -156,12 +156,23 @@ def validate_form_526_change_of_address_state

def validate_form_526_change_of_address_zip
address = form_attributes['changeOfAddress'] || {}
if address['country'] == 'USA' && address['zipFirstFive'].blank?
validate_form_526_usa_coa_conditions(address) if address['country'] == 'USA'
end

def validate_form_526_usa_coa_conditions(address)
if address['zipFirstFive'].blank?
collect_error_messages(
source: '/changeOfAddress/zipFirstFive',
source: '/changeOfAddress/',
detail: 'The zipFirstFive is required if the country is USA.'
)
elsif address['country'] == 'USA' && address['internationalPostalCode'].present?
end
if address['state'].blank?
collect_error_messages(
source: '/changeOfAddress/',
detail: 'The state is required if the country is USA.'
)
end
if address['internationalPostalCode'].present?
collect_error_messages(
source: '/changeOfAddress/internationalPostalCode',
detail: 'The internationalPostalCode should not be provided if the country is USA.'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,36 @@ def current_error_array
end
end

context 'conditional validations when the country is USA' do
context 'zipfirstFive is not included' do
it 'returns an error array' do
subject.form_attributes['changeOfAddress']['zipFirstFive'] = ''
test_526_validation_instance.send(:validate_form_526_change_of_address_zip)
expect(current_error_array[0][:detail]).to eq('The zipFirstFive is required if the country is USA.')
expect(current_error_array[0][:source]).to eq('/changeOfAddress/')
end
end

context 'state is not included' do
it 'returns an error array' do
subject.form_attributes['changeOfAddress']['state'] = ''
test_526_validation_instance.send(:validate_form_526_change_of_address_zip)
expect(current_error_array[0][:detail]).to eq('The state is required if the country is USA.')
expect(current_error_array[0][:source]).to eq('/changeOfAddress/')
end
end

context 'internationalPostalCode is included' do
it 'returns an error array' do
subject.form_attributes['changeOfAddress']['internationalPostalCode'] = '333-444'
test_526_validation_instance.send(:validate_form_526_change_of_address_zip)
expect(current_error_array[0][:detail])
.to eq('The internationalPostalCode should not be provided if the country is USA.')
expect(current_error_array[0][:source]).to eq('/changeOfAddress/internationalPostalCode')
end
end
end
Copy link
Contributor Author

@rockwellwindsor-va rockwellwindsor-va Sep 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This last test was not technically related to the ticket ACs but internationalPostalCode was touched by my refactor in the validations file and since it didn't have a test here I added one.


context 'when the country is not provided' do
it 'returns an error array' do
subject.form_attributes['changeOfAddress']['country'] = ''
Expand Down
Loading