Merge pull request #6798 from betagouv/make_ping_work_again

Corrige le controller ping (health check)
This commit is contained in:
LeSim 2022-01-05 12:24:18 +01:00 committed by GitHub
commit a009871ec1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View file

@ -4,7 +4,7 @@ class PingController < ApplicationController
status_code = if File.file?(Rails.root.join("maintenance"))
# See https://cbonte.github.io/haproxy-dconv/2.0/configuration.html#4.2-http-check%20disable-on-404
:not_found
elsif (ActiveRecord::Base.connected?)
elsif (ActiveRecord::Base.connection.execute('select 1 as test;').first['test'] == 1)
:ok
else
:internal_server_error

View file

@ -6,10 +6,10 @@ describe PingController, type: :controller do
context 'when base is un-plug' do
before do
allow(ActiveRecord::Base).to receive(:connected?).and_return(false)
allow(ActiveRecord::Base).to receive(:connected?).and_raise(ActiveRecord::ConnectionTimeoutError)
end
it { expect(subject.status).to eq 500 }
it { expect { subject }.to raise_error(ActiveRecord::ConnectionTimeoutError) }
end
context 'when a maintenance file is present' do