Skip to content

Commit

Permalink
[API-42887] Remove blank zipLastFour from AutoEstablishedClaim (#19671)
Browse files Browse the repository at this point in the history
* remove blank zipLastFour

* add test

* rename auto_established_claim_spec

* lint
  • Loading branch information
tycol7 authored Dec 2, 2024
1 parent 1836613 commit 805c4cc
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def to_internal # rubocop:disable Metrics/MethodLength
transform_homelessness_point_of_contact_primary_phone!
transform_address_lines_length!
transform_empty_unit_name!
transform_empty_zip_last_four!

{
form526: form_data
Expand Down Expand Up @@ -543,5 +544,11 @@ def transform_empty_unit_name!
unit_name = unit_name.presence || ' '
reserves['unitName'] = unit_name
end

def transform_empty_zip_last_four!
change_of_address = form_data.dig('veteran', 'changeOfAddress')

change_of_address.delete('zipLastFour') if change_of_address.present? && change_of_address['zipLastFour'].blank?
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,25 @@
expect(actual).to eq('HOUSING_WILL_BE_LOST_IN_30_DAYS')
end

it 'removes a blank veteran.changeOfAddress.zipLastFour' do
change_of_address = {
'beginningDate' => 1.month.from_now.to_date.to_s,
'endingDate' => 6.months.from_now.to_date.to_s,
'addressChangeType' => 'TEMPORARY',
'addressLine1' => '1234 Couch Street',
'city' => 'New York City',
'state' => 'NY',
'type' => 'DOMESTIC',
'zipFirstFive' => '12345',
'zipLastFour' => '',
'country' => 'USA'
}

pending_record.form_data['veteran']['changeOfAddress'] = change_of_address
payload = JSON.parse(pending_record.to_internal)
expect(payload['form526']['veteran']['changeOfAddress']).not_to have_key('zipLastFour')
end

context 'when homelessness risk situation type is "other" and "otherLivingSituation" is not provided' do
it 'does not add "otherLivingSituation" to pass EVSS validation' do
temp_form_data = pending_record.form_data
Expand Down Expand Up @@ -221,7 +240,7 @@
end

describe 'handles &amp in service branch for separation pay' do
it ' and retrieves payment' do
it 'and retrieves payment' do
temp_form_data = pending_record.form_data
temp_form_data.merge!(
{
Expand All @@ -247,7 +266,7 @@
end

describe 'handles &amp in service branch for militaryRetiredPay' do
it ' and retrieves payment' do
it 'and retrieves payment' do
temp_form_data = pending_record.form_data
temp_form_data.merge!(
{
Expand All @@ -273,7 +292,7 @@
end

describe 'handles & in service branch for militaryRetiredPay' do
it ' and retrieves payment' do
it 'and retrieves payment' do
temp_form_data = pending_record.form_data
temp_form_data.merge!(
{
Expand Down Expand Up @@ -321,7 +340,7 @@
context "when 'changeOfAddress' is provided" do
let(:change_of_address) do
{
'beginningDate' => (Time.zone.now + 1.month).to_date.to_s,
'beginningDate' => 1.month.from_now.to_date.to_s,
'endingDate' => ending_date,
'addressChangeType' => address_change_type,
'addressLine1' => '1234 Couch Street',
Expand All @@ -332,7 +351,7 @@
'country' => 'USA'
}
end
let(:ending_date) { (Time.zone.now + 6.months).to_date.to_s }
let(:ending_date) { 6.months.from_now.to_date.to_s }

context "when 'changeOfAddress.addressChangeType' is 'TEMPORARY'" do
let(:address_change_type) { 'TEMPORARY' }
Expand Down Expand Up @@ -380,7 +399,7 @@
let(:address_change_type) { 'PERMANENT' }

context "and 'changeOfAddress.endingDate' is provided" do
let(:ending_date) { (Time.zone.now + 6.months).to_date.to_s }
let(:ending_date) { 6.months.from_now.to_date.to_s }

it "removes the 'changeOfAddress.endingDate'" do
pending_record.form_data['veteran']['changeOfAddress'] = change_of_address
Expand Down Expand Up @@ -579,13 +598,13 @@

context 'with no record' do
it 'returns nil' do
expect(described_class.evss_id_by_token('thisisntatoken')).to be(nil)
expect(described_class.evss_id_by_token('thisisntatoken')).to be_nil
end
end

context 'with record without evss id' do
it 'returns nil' do
expect(described_class.evss_id_by_token(pending_record.token)).to be(nil)
expect(described_class.evss_id_by_token(pending_record.token)).to be_nil
end
end
end
Expand All @@ -609,7 +628,7 @@
describe '#set_file_data!' do
it 'stores the file_data and give me a full evss document' do
file = Rack::Test::UploadedFile.new(
::Rails.root.join(*'/modules/claims_api/spec/fixtures/extras.pdf'.split('/')).to_s
Rails.root.join(*'/modules/claims_api/spec/fixtures/extras.pdf'.split('/')).to_s
)

auto_form.set_file_data!(file, 'docType')
Expand Down Expand Up @@ -650,7 +669,7 @@
end

context "when 'treatments.startDate' is not included" do
it "does not include 'treatment.startDate' after transformation " do
it "does not include 'treatment.startDate' after transformation" do
treatments = [
{
'center' => {
Expand Down Expand Up @@ -785,7 +804,7 @@

context "when a 'disability.name' only has valid characters" do
it 'nothing is changed' do
name_with_only_valid_characters = "abc \-'.,/()123"
name_with_only_valid_characters = "abc -'.,/()123"
pending_record.form_data['disabilities'].first['name'] = name_with_only_valid_characters

payload = JSON.parse(pending_record.to_internal)
Expand Down Expand Up @@ -825,7 +844,7 @@
it "does not erase the 'file_data' attribute" do
auto_form = build(:auto_established_claim, :established, auth_headers: { some: 'data' })
file = Rack::Test::UploadedFile.new(
::Rails.root.join(*'/modules/claims_api/spec/fixtures/extras.pdf'.split('/')).to_s
Rails.root.join(*'/modules/claims_api/spec/fixtures/extras.pdf'.split('/')).to_s
)

auto_form.set_file_data!(file, 'docType')
Expand Down

0 comments on commit 805c4cc

Please sign in to comment.