Skip to content

Commit

Permalink
reinstate error test in association spec
Browse files Browse the repository at this point in the history
  • Loading branch information
liztownd committed Nov 14, 2024
1 parent 01003cb commit ec1f5d6
Showing 1 changed file with 30 additions and 19 deletions.
49 changes: 30 additions & 19 deletions modules/travel_pay/spec/services/claims_association_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,18 @@
)
end

let(:claims_error_response) do
Faraday::Response.new(
response_body: {
'statusCode' => 401,
'message' => 'Unauthorized.',
'success' => false,
'data' => nil
},
status: 401
)
end

let(:single_appointment) do
{
'id' => '32066',
Expand Down Expand Up @@ -256,26 +268,25 @@
expect(appt_with_claim['travelPayClaim']['claim']).to be_nil
end

# TODO: needs work
# it 'returns appointment with error metadata if claims call fails' do
# allow_any_instance_of(TravelPay::ClaimsService)
# .to receive(:get_claims_by_date_range)
# .with(
# { 'start_date' => '2024-01-01T16:45:34Z',
# 'end_date' => '2024-01-01T16:45:34Z' }
# )
# .and_return(nil)
it 'returns appointment with error metadata if claims call fails' do
allow_any_instance_of(TravelPay::ClaimsService)
.to receive(:get_claims_by_date_range)
.with(
{ 'start_date' => '2024-01-01T16:45:34Z',
'end_date' => '2024-01-01T16:45:34Z' }
)
.and_return(claims_error_response)

# association_service = TravelPay::ClaimAssociationService.new(user)
# appt_with_claim = association_service.associate_single_appointment_to_claim(
# { 'appointment' => single_appointment }
# )
association_service = TravelPay::ClaimAssociationService.new(user)
appt_with_claim = association_service.associate_single_appointment_to_claim(
{ 'appointment' => single_appointment }
)

# expect(appt_with_claim['travelPayClaim']['claim']).to be_nil
# expect(appt_with_claim['travelPayClaim']['metadata']['status']).to equal(503)
# expect(appt_with_claim['travelPayClaim']['metadata']['message'])
# .to eq('Travel Pay service unavailable.')
# expect(appt_with_claim['travelPayClaim']['metadata']['success']).to eq(false)
# end
expect(appt_with_claim['travelPayClaim']['claim']).to be_nil
expect(appt_with_claim['travelPayClaim']['metadata']['status']).to equal(401)
expect(appt_with_claim['travelPayClaim']['metadata']['message'])
.to eq('Unauthorized.')
expect(appt_with_claim['travelPayClaim']['metadata']['success']).to eq(false)
end
end
end

0 comments on commit ec1f5d6

Please sign in to comment.