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-41802-empty-unit-test #19305

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 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 @@ -25,6 +25,8 @@ def validate_form_526_submission_values!
validate_service_after_13th_birthday!
# ensure 'militaryRetiredPay.receiving' and 'militaryRetiredPay.willReceiveInFuture' are not same non-null values
validate_form_526_service_pay!
# ensure an error is avoided if the unit name is not provided
transform_form_526_unit_name!
# ensure 'title10ActivationDate' if provided, is after the earliest servicePeriod.activeDutyBeginDate and on or before the current date # rubocop:disable Layout/LineLength
validate_form_526_title10_activation_date!
# ensure 'title10Activation.anticipatedSeparationDate' is in the future
Expand Down Expand Up @@ -140,6 +142,15 @@ def validate_form_526_title10_anticipated_separation_date!
)
end

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

unit_name = reserves['unitName']
unit_name = unit_name.presence || ' '
reserves['unit_name'] = unit_name
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
reserves['unit_name'] = unit_name
reserves['unitName'] = unit_name

end

Copy link
Contributor

@rockwellwindsor-va rockwellwindsor-va Nov 7, 2024

Choose a reason for hiding this comment

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

@stiehlrod Apologies for being so late to the party here, trying to get to these, This is a transform basically just for the docker container I believe. Wondering if this would be better off in the auto_established_claim model where other transforms are? I think we really only need this for when .to_internal gets called before sending to the docker container similar to something like the previous unit phone transform, thoughts?

Copy link
Contributor

@rockwellwindsor-va rockwellwindsor-va Nov 7, 2024

Choose a reason for hiding this comment

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

You would also then be able to test the returns in modules/claims_api/spec/models/auto_establish_claim_spec.rb I to check for any expected values like making sure it did transform into " "

def validate_form_526_submission_claim_date!
return if form_attributes['claimDate'].blank?
return if DateTime.parse(form_attributes['claimDate']) <= Time.zone.now
Expand Down
54 changes: 54 additions & 0 deletions modules/claims_api/spec/requests/v1/forms/526_spec.rb
stiehlrod marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,60 @@
end
end
end

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

it 'returns a successful response' do
stiehlrod marked this conversation as resolved.
Show resolved Hide resolved
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)
end
end
end
end
end

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

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(:unprocessable_entity)
end
end
end
end
end

context "when 'unitName' is not present" do
it 'returns a successful response' do
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
it 'returns a successful response' do
it 'returns an unprocessable entity 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
end

Expand Down
Loading