2016-12-15 15:31:05 +01:00
|
|
|
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
|
2023-09-07 15:51:56 +02:00
|
|
|
allow(ActiveRecord::Base).to receive(:connection).and_raise(ActiveRecord::ConnectionTimeoutError)
|
2016-12-15 15:31:05 +01:00
|
|
|
end
|
|
|
|
|
2022-01-05 10:53:14 +01:00
|
|
|
it { expect { subject }.to raise_error(ActiveRecord::ConnectionTimeoutError) }
|
2016-12-15 15:31:05 +01:00
|
|
|
end
|
2020-06-21 18:34:59 +02:00
|
|
|
|
|
|
|
context 'when a maintenance file is present' do
|
2023-04-19 10:55:16 +02:00
|
|
|
let(:filepath) { Rails.root.join('maintenance') }
|
2020-06-21 18:34:59 +02:00
|
|
|
before do
|
2023-04-19 10:55:16 +02:00
|
|
|
filepath.write("")
|
|
|
|
end
|
|
|
|
|
|
|
|
after do
|
|
|
|
filepath.delete
|
2020-06-21 18:34:59 +02:00
|
|
|
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
|
2016-12-15 15:31:05 +01:00
|
|
|
end
|
2017-04-04 15:27:04 +02:00
|
|
|
end
|