demarches-normaliennes/spec/controllers/ping_controller_spec.rb
simon lehericey 00871cfe13 Fix ping controller in dev
For an unknown reason, ActiveRecord::Base.connected? does not work anymore in dev. It returns false negative.

This simple workaround can timeout. The caller has to monitor the response time.
2022-01-05 11:44:32 +01:00

25 lines
708 B
Ruby

describe PingController, type: :controller do
describe 'GET #index' do
subject { get :index }
it { expect(subject.status).to eq 200 }
context 'when base is un-plug' do
before do
allow(ActiveRecord::Base).to receive(:connected?).and_raise(ActiveRecord::ConnectionTimeoutError)
end
it { expect { subject }.to raise_error(ActiveRecord::ConnectionTimeoutError) }
end
context 'when a maintenance file is present' do
before do
allow(File).to receive(:file?).and_return(true)
end
it 'tells HAProxy that the app is in maintenance, but will be available again soon' do
expect(subject.status).to eq 404
end
end
end
end