summaryrefslogtreecommitdiff
path: root/spec/features/admin/admin_health_check_spec.rb
diff options
context:
space:
mode:
authorDJ Mountney <david@twkie.net>2016-05-10 16:19:16 -0700
committerDJ Mountney <david@twkie.net>2016-05-10 16:19:16 -0700
commit0e0caf4d17c28b6b0f3488b25efa265ce2804cc4 (patch)
tree13d7c57892acf74c88b41fbac0188383169f20dd /spec/features/admin/admin_health_check_spec.rb
parent160ef66d1bbbbc593516c7575d6b02ddb019c000 (diff)
downloadgitlab-ce-0e0caf4d17c28b6b0f3488b25efa265ce2804cc4.tar.gz
Add tests for the health check feature
Diffstat (limited to 'spec/features/admin/admin_health_check_spec.rb')
-rw-r--r--spec/features/admin/admin_health_check_spec.rb55
1 files changed, 55 insertions, 0 deletions
diff --git a/spec/features/admin/admin_health_check_spec.rb b/spec/features/admin/admin_health_check_spec.rb
new file mode 100644
index 00000000000..4fde04b609b
--- /dev/null
+++ b/spec/features/admin/admin_health_check_spec.rb
@@ -0,0 +1,55 @@
+require 'spec_helper'
+
+feature "Admin Health Check", feature: true do
+ include WaitForAjax
+
+ before do
+ login_as :admin
+ end
+
+ describe '#show' do
+ before do
+ visit admin_health_check_path
+ end
+
+ it { page.has_text? 'Health Check' }
+ it { page.has_text? 'Health information can be reteived' }
+
+ it 'has a health check access token' do
+ token = current_application_settings.health_check_access_token
+ 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