Skip to content

Commit

Permalink
Merge branch 'k8s' into rcassity-checkout-main-branch
Browse files Browse the repository at this point in the history
  • Loading branch information
rmtolmach authored Apr 25, 2024
2 parents a638d1d + 8ce02ab commit e0524f6
Show file tree
Hide file tree
Showing 10 changed files with 142 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ GEM
stringio (3.1.0)
strong_migrations (1.8.0)
activerecord (>= 5.2)
super_diff (0.11.0)
super_diff (0.12.0)
attr_extras (>= 6.2.4)
diff-lcs
patience_diff
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def translate
output_form.update(translate_veteran)
output_form.update(translate_treatments)
output_form.update(translate_disabilities)
output_form.update(add_toxic_exposure) if Flipper.enabled?(:disability_526_toxic_exposure, @current_user)

@translated_form
end
Expand Down Expand Up @@ -629,6 +630,14 @@ def map_secondary(input_disability, disabilities)
end
end

###
# Toxic Exposure
###

def add_toxic_exposure
{ 'toxicExposure' => input_form['toxicExposure'] }
end

def application_expiration_date
1.year.from_now.iso8601
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class InquiriesController < ApplicationController
around_action :handle_exceptions
before_action :get_inquiries_by_icn, only: [:index]
before_action :get_inquiry_by_id, only: [:show]
skip_before_action :authenticate, only: %i[unauth_create upload_attachment test_create]
skip_before_action :authenticate, only: %i[unauth_create upload_attachment test_create show]
skip_before_action :verify_authenticity_token, only: %i[unauth_create upload_attachment test_create]

def index
Expand Down Expand Up @@ -63,6 +63,8 @@ def create_reply
private

def get_inquiry_by_id
entity_class = AskVAApi::Inquiries::Entity
retriever = Inquiries::Retriever.new(user_mock_data: params[:mock], entity_class:)
inq = retriever.fetch_by_id(id: params[:id])
@inquiry = Result.new(payload: Inquiries::Serializer.new(inq).serializable_hash, status: :ok)
end
Expand Down
7 changes: 6 additions & 1 deletion modules/ask_va_api/app/lib/ask_va_api/inquiries/retriever.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ def filter_data(data, id = nil)
end

def handle_response_data(response)
response[:Data].presence || raise(InquiriesRetrieverError, response[:Message])
if response[:Data].nil?
error = JSON.parse(response[:body], symbolize_names: true)
raise InquiriesRetrieverError, error[:Message]
else
response[:Data]
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,23 @@
describe '#call' do
context 'when Crm raise an error' do
let(:icn) { '123' }
let(:response) do
{ Data: nil,
Message: 'Data Validation: No Contact found by ICN',
ExceptionOccurred: true,
ExceptionMessage: 'Data Validation: No Contact found by ICN',
MessageId: '2733ca25-7e64-4fbc-af2c-366f4bd2e3dc' }
let(:body) do
'{"Data":null,"Message":"Data Validation: No Inquiries found by ID A-20240423-30709"' \
',"ExceptionOccurred":true,"ExceptionMessage":"Data Validation: No Inquiries found by ' \
'ID A-20240423-30709","MessageId":"ca5b990a-63fe-407d-a364-46caffce12c1"}'
end
let(:failure) do
{
status: 400,
body:,
response_headers: nil,
url: nil
}
end

before do
allow_any_instance_of(Crm::CrmToken).to receive(:call).and_return('Token')
allow(service).to receive(:call).and_return(response)
allow(service).to receive(:call).and_return(failure)
end

it 'raise CorrespondenceRetrieverrError' do
Expand Down
30 changes: 14 additions & 16 deletions modules/ask_va_api/spec/requests/v0/inquiries_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,19 +207,25 @@
end

context 'when the id is invalid' do
let(:crm_response) do
{ Data: nil,
Message: 'Data Validation: No Inquiries found by ID A-20230305-30617',
ExceptionOccurred: true,
ExceptionMessage: 'Data Validation: No Inquiries found by ID A-20230305-30617',
MessageId: 'e6024ccb-e19b-4bc6-990c-667e7ebab4ec' }
let(:body) do
'{"Data":null,"Message":"Data Validation: No Inquiries found by ID A-20240423-30709"' \
',"ExceptionOccurred":true,"ExceptionMessage":"Data Validation: No Inquiries found by ' \
'ID A-20240423-30709","MessageId":"ca5b990a-63fe-407d-a364-46caffce12c1"}'
end
let(:failure) do
{
status: 400,
body:,
response_headers: nil,
url: nil
}
end
let(:service) { instance_double(Crm::Service) }

before do
allow(Crm::Service).to receive(:new).and_return(service)
allow_any_instance_of(Crm::CrmToken).to receive(:call).and_return('Token')
allow(service).to receive(:call).and_return(crm_response)
allow(service).to receive(:call).and_return(failure)
sign_in(authorized_user)
get "#{inquiry_path}/#{invalid_id}"
end
Expand All @@ -228,17 +234,9 @@

it_behaves_like 'common error handling', :unprocessable_entity, 'service_error',
'AskVAApi::Inquiries::InquiriesRetrieverError: ' \
'Data Validation: No Inquiries found by ID A-20230305-30617'
'Data Validation: No Inquiries found by ID A-20240423-30709'
end
end

context 'when user is not signed in' do
before do
get "#{inquiry_path}/#{valid_id}"
end

it { expect(response).to have_http_status(:unauthorized) }
end
end

describe 'GET #download_attachment' do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1451,6 +1451,36 @@
end
end

describe '#add_toxic_exposure' do
let(:form_content) do
{
'form526' => {
'toxicExposure' => {
'gulfWar1990' => {
'iraq' => true,
'kuwait' => true,
'qatar' => true
}
}
}
}
end

it 'returns toxic exposure' do
expect(subject.send(:add_toxic_exposure)).to eq(
{
'toxicExposure' => {
'gulfWar1990' => {
'iraq' => true,
'kuwait' => true,
'qatar' => true
}
}
}
)
end
end

describe '#application_expiration_date' do
it 'returns the application creation date + 365 days' do
expect(subject.send(:application_expiration_date)).to eq '2021-11-05T18:19:50Z'
Expand Down
2 changes: 2 additions & 0 deletions spec/requests/disability_compensation_form_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ def test_error(cassette_path, status, headers)
post('/v0/disability_compensation_form/submit_all_claim', params: all_claims_form, headers:)
expect(response).to have_http_status(:ok)
expect(response).to match_response_schema('submit_disability_form')
form = Form526Submission.last.form
expect(form.dig('form526', 'form526', 'toxicExposure')).not_to eq(nil)
end

it 'matches the rated disabilites schema with camel-inflection' do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
]
}
],
"toxicExposure": {},
"waiveRetirementPay": false,
"waiveTrainingPay": true,
"hasTrainingPay": true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,69 @@
}
]
}
]
],
"toxicExposure": {
"gulfWar1990": {
"iraq": true,
"kuwait": true,
"qatar": true
},
"gulfWar1990Details": {
"iraq": {
"startDate": "1991-03-01",
"endDate": "1992-01-01"
},
"qatar": {
"startDate": "1991-02-12",
"endDate": "1991-06-01"
},
"kuwait": {
"startDate": "1991-03-15"
}
},
"herbicide": {
"cambodia": true,
"guam": true,
"laos": true
},
"herbicideDetails": {
"cambodia": {
"startDate": "1991-03-01",
"endDate": "1992-01-01"
},
"guam": {
"startDate": "1991-02-12",
"endDate": "1991-06-01"
},
"laos": {
"startDate": "1991-03-15"
}
},
"otherHerbicideLocations": "freeform text field.",
"otherExposures": {
"asbestos": true,
"radiation": true,
"mustardgas": false
},
"otherExposureDetails": {
"asbestos": {
"startDate": "1991-03-01",
"endDate": "1992-01-01"
},
"radiation": {
"startDate": "1991-03-01",
"endDate": "1992-01-01"
}
},
"specifyOtherExposures": {
"description": "Lead, burn pits",
"startDate": "1991-03-01",
"endDate": "1992-01-01"
},
"conditions": {
"deviatedseptum": true
}
}
}
},
"form526_uploads": [
Expand Down

0 comments on commit e0524f6

Please sign in to comment.