Skip to content

Commit

Permalink
Fix specs for TravelPay::ClaimsController
Browse files Browse the repository at this point in the history
  • Loading branch information
Athif Wulandana committed Mar 6, 2024
1 parent 9d70123 commit 8dcca09
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions modules/travel_pay/spec/controllers/claims_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,38 @@

require 'rails_helper'

RSpec.describe TravelPay::ClaimsController, type: :controller do
RSpec.describe TravelPay::ClaimsController, type: :request do
let(:user) { build(:user) }

before do
veis_response = double
allow(veis_response).to receive(:body).and_return( {'access_token' => 'sample_token'} )
allow_any_instance_of(TravelPay::Client).to receive(:request_veis_token).and_return(veis_response)
btsss_ping_response = double
allow(btsss_ping_response).to receive(:status).and_return('online')
allow_any_instance_of(TravelPay::Client).to receive(:ping).and_return(btsss_ping_response)
sign_in(user)
Flipper.disable :travel_pay_power_switch
end

describe '#index' do
it 'requests a token and sends a ping to BTSSS' do
get(:index)
expect(response.body).to eq('Received ping from upstream server with status online.')
context 'the feature switch is enabled' do
before do
Flipper.enable :travel_pay_power_switch
end

it 'requests a token and sends a ping to BTSSS' do
get '/travel_pay/claims'
expect(response.body).to include('Received ping from upstream server with status online.')
end
end

context 'the feature switch is disabled' do
it 'raises the proper error' do
get '/travel_pay/claims'
expect(response).to have_http_status(503)
expect(response.body).to include('This feature has been temporarily disabled')
end
end
end
end

0 comments on commit 8dcca09

Please sign in to comment.