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

Mobile: Create EVSSClaim even when using lighthouse #16337

Merged
merged 3 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -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
Expand All @@ -33,6 +35,21 @@ 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)
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

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

I would write this as:

expect {
  get('/mobile/v0/claims-and-appeals-overview', headers: sis_headers, params:)
}.to change(EVSSClaim, :count).by(1)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I originally was going to write it that way, but I thought the get being in a block would mess up the response variable. I guess not though, I'm changing it

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']
Expand Down
Loading