-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- This application does not have Honeybadger, so skipping the Honeybadger notification Closes #213
- Loading branch information
Showing
6 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
Rails.application.config.after_initialize do | ||
HealthMonitor.configure do |config| | ||
# Make this health check available at /health | ||
config.path = :health | ||
|
||
config.error_callback = proc do |e| | ||
Rails.logger.error "Health check failed with: #{e.message}" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe 'Health Check' do | ||
describe 'GET /health' do | ||
it 'has a health check' do | ||
get '/health.json' | ||
expect(response).to be_successful | ||
end | ||
end | ||
|
||
context 'with a bad database configuration' do | ||
before do | ||
allow_any_instance_of(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter).to receive(:execute) do |instance| | ||
raise StandardError if database.blank? || instance.pool.db_config.name == database.to_s | ||
end | ||
end | ||
|
||
it 'errors' do | ||
get '/health.json' | ||
expect(response).not_to be_successful | ||
expect(response).to have_http_status :service_unavailable | ||
end | ||
end | ||
end |