From d9e288e5cb746c1f6eb47ce6422a1fe0ed50f50c Mon Sep 17 00:00:00 2001 From: Tonksthebear Date: Mon, 15 Apr 2024 09:58:40 -0700 Subject: [PATCH] Create EVSSClaim even when using lighthouse --- .../mobile/v0/lighthouse_claims/proxy.rb | 22 +++++++++++++++++-- ...laims_and_appeals_overview_request_spec.rb | 2 ++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/modules/mobile/app/services/mobile/v0/lighthouse_claims/proxy.rb b/modules/mobile/app/services/mobile/v0/lighthouse_claims/proxy.rb index 62ffba0da04..b742e3b1060 100644 --- a/modules/mobile/app/services/mobile/v0/lighthouse_claims/proxy.rb +++ b/modules/mobile/app/services/mobile/v0/lighthouse_claims/proxy.rb @@ -14,12 +14,14 @@ def request_decision(id) claims_service.submit5103(@user, id) end + # Temporary: We're adding the claims to the EVSSClaim table until decision letters switch over to lighthouse def get_all_claims lambda { begin - claims_list = claims_service.get_claims + claims_list = claims_service.get_claims['data'] + claims_list.each { |claim| create_or_update_claim(claim) } { - list: claims_list['data'], + list: claims_list, errors: nil } rescue => e @@ -33,6 +35,22 @@ def get_all_claims def claims_service @claims_service ||= BenefitsClaims::Service.new(@user.icn) end + + def claims_scope + @claims_scope ||= EVSSClaim.for_user(@user) + end + + def create_or_update_claim(raw_claim) + claim = claims_scope.where(evss_id: raw_claim['id']).first + if claim.blank? + claim = EVSSClaim.new(user_uuid: @user.uuid, + user_account: @user.user_account, + evss_id: raw_claim['id'], + data: {}) + end + claim.update(list_data: raw_claim) + claim + end end end end diff --git a/modules/mobile/spec/request/claims_and_appeals_overview_request_spec.rb b/modules/mobile/spec/request/claims_and_appeals_overview_request_spec.rb index 843ade084d9..dfb4f929a8a 100644 --- a/modules/mobile/spec/request/claims_and_appeals_overview_request_spec.rb +++ b/modules/mobile/spec/request/claims_and_appeals_overview_request_spec.rb @@ -48,7 +48,9 @@ it 'and a result that matches our schema is successfully returned with the 200 status ' do VCR.use_cassette(good_claims_response_vcr_path) do VCR.use_cassette('mobile/appeals/appeals') do + original_evss_claims_count = EVSSClaim.count get('/mobile/v0/claims-and-appeals-overview', headers: sis_headers, params:) + expect(EVSSClaim.count).not_to eq(original_evss_claims_count) expect(response).to have_http_status(:ok) # check a couple entries to make sure the data is correct parsed_response_contents = response.parsed_body['data']