Skip to content
This repository is currently being migrated. It's locked while the migration is in progress.

Commit 259642c

Browse files
authored
1468: Fix map nil error (#27414)
1 parent 074483a commit 259642c

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

lib/disability_compensation/providers/rated_disabilities/lighthouse_rated_disabilities_provider.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def get_combined_disability_rating(lighthouse_client_id = nil, lighthouse_rsa_ke
2727
# @option options [string] :invoker where this method was called from
2828
def get_rated_disabilities(lighthouse_client_id = nil, lighthouse_rsa_key_path = nil, options = {})
2929
data = get_data(lighthouse_client_id, lighthouse_rsa_key_path, options)
30-
transform(data['data']['attributes']['individual_ratings'])
30+
transform(data.dig('data', 'attributes', 'individual_ratings') || [])
3131
end
3232

3333
# @param [string] lighthouse_client_id: the lighthouse_client_id requested from Lighthouse

spec/lib/disability_compensation/providers/rated_disabilities/lighthouse_rated_disabilities_provider_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@
2626
end
2727
end
2828

29+
it 'returns an empty list when individual_ratings is nil' do
30+
allow_any_instance_of(VeteranVerification::Service).to receive(:get_rated_disabilities).and_return(
31+
{ 'data' => { 'attributes' => { 'individual_ratings' => nil } } }
32+
)
33+
response = @provider.get_rated_disabilities('', '')
34+
expect(response.rated_disabilities).to eq([])
35+
end
36+
2937
it 'returns the proper error through the Timeout class' do
3038
allow_any_instance_of(Faraday::Connection).to receive(:get).and_raise(Faraday::TimeoutError)
3139
expect do

0 commit comments

Comments
 (0)