From aa4e8bf45fb4aa5ff3ab92490ba4ca9478587650 Mon Sep 17 00:00:00 2001 From: Tonksthebear Date: Mon, 15 Apr 2024 15:14:26 -0700 Subject: [PATCH] Update tests to be better --- ...laims_and_appeals_overview_request_spec.rb | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) 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 dfb4f929a8a..6bcf8c46bf1 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,9 +48,7 @@ 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'] @@ -487,6 +485,36 @@ end end end + + describe 'EVSSClaim count' do + it 'creates record if it does not exist' do + VCR.use_cassette(good_claims_response_vcr_path) do + VCR.use_cassette('mobile/appeals/appeals') do + expect do + get('/mobile/v0/claims-and-appeals-overview', headers: sis_headers, params:) + end.to change(EVSSClaim, :count) + end + end + end + + it 'updates record if it does exist' do + VCR.use_cassette(good_claims_response_vcr_path) do + VCR.use_cassette('mobile/appeals/appeals') do + evss_id = lighthouse_flag ? 600_383_363 : 600_114_693 + claim = EVSSClaim.create(user_uuid: sis_user.uuid, + user_account: sis_user.user_account, + evss_id:, + created_at: 1.week.ago, + updated_at: 1.week.ago, + data: {}) + expect do + get('/mobile/v0/claims-and-appeals-overview', headers: sis_headers, params:) + claim.reload + end.to change(claim, :updated_at) + end + end + end + end end end