Skip to content

Commit

Permalink
Don't set vaCompensationType when disability rating is nil (#11930)
Browse files Browse the repository at this point in the history
* return from prefill_compensation_type if disability rating is nil

* lint
  • Loading branch information
lihanli authored Mar 8, 2023
1 parent 49f937e commit 817ec2d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/models/health_care_application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ def prefill_compensation_type
rating_info_service = EVSS::CommonService.new(auth_headers)
response = rating_info_service.get_rating_info

return if response.user_percent_of_disability.nil?

Raven.extra_context(disability_rating: response.user_percent_of_disability)

parsed_form['vaCompensationType'] = 'highDisability' if response.user_percent_of_disability >= DISABILITY_THRESHOLD
Expand Down
14 changes: 14 additions & 0 deletions spec/models/health_care_application_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@
end
end

context 'when disability_rating is nil' do
it 'does nothing' do
expect_any_instance_of(EVSS::CommonService).to receive(
:get_rating_info
).and_return(OpenStruct.new(user_percent_of_disability: nil))

expect(health_care_application).not_to receive(:log_exception_to_sentry)

health_care_application.send(:prefill_compensation_type)

expect(health_care_application.parsed_form['vaCompensationType']).to eq(nil)
end
end

context 'with an error' do
it 'logs to sentry and doesnt raise the error' do
expect(health_care_application).to receive(:log_exception_to_sentry)
Expand Down

0 comments on commit 817ec2d

Please sign in to comment.