2016-05-10 19:19:16 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
feature "Admin Health Check", feature: true do
|
2017-01-21 19:11:19 -05:00
|
|
|
include StubENV
|
2016-05-10 19:19:16 -04:00
|
|
|
include WaitForAjax
|
|
|
|
|
|
|
|
before do
|
2017-01-21 19:11:19 -05:00
|
|
|
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
|
2016-05-10 19:19:16 -04:00
|
|
|
login_as :admin
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#show' do
|
|
|
|
before do
|
|
|
|
visit admin_health_check_path
|
|
|
|
end
|
|
|
|
|
2017-01-21 17:55:35 -05:00
|
|
|
it 'has a health check access token' do
|
2017-01-21 19:11:19 -05:00
|
|
|
page.has_text? 'Health Check'
|
|
|
|
page.has_text? 'Health information can be retrieved'
|
|
|
|
|
2016-05-10 19:19:16 -04:00
|
|
|
token = current_application_settings.health_check_access_token
|
2017-01-21 19:11:19 -05:00
|
|
|
|
2016-05-10 19:19:16 -04:00
|
|
|
expect(page).to have_content("Access token is #{token}")
|
|
|
|
expect(page).to have_selector('#health-check-token', text: token)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'reload access token', js: true do
|
|
|
|
it 'changes the access token' do
|
|
|
|
orig_token = current_application_settings.health_check_access_token
|
|
|
|
click_button 'Reset health check access token'
|
|
|
|
wait_for_ajax
|
|
|
|
expect(find('#health-check-token').text).not_to eq orig_token
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when services are up' do
|
|
|
|
before do
|
|
|
|
visit admin_health_check_path
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows healthy status' do
|
|
|
|
expect(page).to have_content('Current Status: Healthy')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when a service is down' do
|
|
|
|
before do
|
|
|
|
allow(HealthCheck::Utils).to receive(:process_checks).and_return('The server is on fire')
|
|
|
|
visit admin_health_check_path
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows unhealthy status' do
|
|
|
|
expect(page).to have_content('Current Status: Unhealthy')
|
|
|
|
expect(page).to have_content('The server is on fire')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|