Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into liz/add-better-erro…
Browse files Browse the repository at this point in the history
…r-handling
  • Loading branch information
liztownd committed Nov 14, 2024
2 parents 516370d + ab28b3e commit c49da11
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ gem 'connect_vbms', git: 'https://github.com/adhocteam/connect_vbms', tag: 'v2.1
gem 'csv'
gem 'date_validator'
gem 'ddtrace'
gem 'dogstatsd-ruby', '5.6.2'
gem 'dogstatsd-ruby', '5.6.3'
gem 'dry-struct'
gem 'dry-types'
gem 'ethon', '>=0.13.0'
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ GEM
thread_safe (~> 0.3, >= 0.3.1)
diff-lcs (1.5.1)
docile (1.4.0)
dogstatsd-ruby (5.6.2)
dogstatsd-ruby (5.6.3)
domain_name (0.6.20240107)
down (5.4.2)
addressable (~> 2.8)
Expand Down Expand Up @@ -1162,7 +1162,7 @@ DEPENDENCIES
ddtrace
debts_api!
dhp_connected_devices!
dogstatsd-ruby (= 5.6.2)
dogstatsd-ruby (= 5.6.3)
dry-struct
dry-types
ethon (>= 0.13.0)
Expand Down
10 changes: 10 additions & 0 deletions modules/claims_api/app/models/claims_api/auto_established_claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def to_internal # rubocop:disable Metrics/MethodLength
resolve_homelessness_risk_situation_type_mappings!
transform_homelessness_point_of_contact_primary_phone!
transform_address_lines_length!
transform_empty_unit_name!

{
form526: form_data
Expand Down Expand Up @@ -533,5 +534,14 @@ def transform_address_lines_length!

form_data['veteran']['currentMailingAddress'] = addr
end

def transform_empty_unit_name!
reserves = form_data&.dig('serviceInformation', 'reservesNationalGuardService')
return if reserves.nil?

unit_name = reserves['unitName']
unit_name = unit_name.presence || ' '
reserves['unitName'] = unit_name
end
end
end
15 changes: 15 additions & 0 deletions modules/claims_api/spec/models/auto_establish_claim_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,21 @@
end
end

describe '#transform_empty_unit_name!' do
let(:unit_name) { '' }

it 'trasforms an empty unit name to a space' do
temp_form_data = pending_record.form_data
temp_form_data['serviceInformation']['reservesNationalGuardService']['unitName'] = unit_name

pending_record.form_data = temp_form_data
payload = JSON.parse(pending_record.to_internal)
name = payload['form526']['serviceInformation']['reservesNationalGuardService']['unitName']

expect(name).to eq(' ')
end
end

describe 'evss_id_by_token' do
context 'with a record' do
let(:evss_record) { create(:auto_established_claim, evss_id: 123_456) }
Expand Down
59 changes: 59 additions & 0 deletions modules/claims_api/spec/requests/v1/forms/526_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,65 @@
end
end
end

context "when 'unitName' is empty" do
let(:unit_name) { '' }

it 'returns a successful response' do
mock_acg(scopes) do |auth_header|
VCR.use_cassette('claims_api/bgs/claims/claims') do
VCR.use_cassette('claims_api/brd/countries') do
par = json_data
par['data']['attributes']['serviceInformation']['reservesNationalGuardService']['unitName'] =
unit_name

post path, params: par.to_json, headers: headers.merge(auth_header)
expect(response).to have_http_status(:ok)
response_body = JSON.parse(response.body)
claim_id = response_body['data']['id']
claim = ClaimsApi::AutoEstablishedClaim.find(claim_id)
claim.to_internal
expect(claim.form_data['serviceInformation']['reservesNationalGuardService']['unitName']).to eq(' ')
end
end
end
end
end

context "when 'unitName' is nil" do
let(:unit_name) { nil }

it 'returns a unsuccessful response' do
mock_acg(scopes) do |auth_header|
VCR.use_cassette('claims_api/bgs/claims/claims') do
VCR.use_cassette('claims_api/brd/countries') do
par = json_data
par['data']['attributes']['serviceInformation']['reservesNationalGuardService']['unitName'] =
unit_name

post path, params: par.to_json, headers: headers.merge(auth_header)
expect(response).to have_http_status(:unprocessable_entity)
end
end
end
end
end

context "when 'unitName' is not present" do
it 'returns a unsuccessful response' do
mock_acg(scopes) do |auth_header|
VCR.use_cassette('claims_api/bgs/claims/claims') do
VCR.use_cassette('claims_api/brd/countries') do
par = json_data
par['data']['attributes']['serviceInformation']['reservesNationalGuardService'].delete('unitName')

post path, params: par.to_json, headers: headers.merge(auth_header)
expect(response).to have_http_status(:unprocessable_entity)
end
end
end
end
end
end

context '526 submission payload validations' do
Expand Down

0 comments on commit c49da11

Please sign in to comment.