summaryrefslogtreecommitdiff
path: root/spec/controllers
diff options
context:
space:
mode:
authorPawel Chojnacki <pawel@chojnacki.ws>2017-07-05 00:12:21 +0200
committerPawel Chojnacki <pawel@chojnacki.ws>2017-07-05 00:46:12 +0200
commit6d60e265b1bb0212803d301d723c12affe366397 (patch)
treefd2249217a62119d6f1818e4e7ebbb484398b7fe /spec/controllers
parent2f875c40374597ca98104cd40a357a9a928335ff (diff)
downloadgitlab-ce-6d60e265b1bb0212803d301d723c12affe366397.tar.gz
Add spaces between test phases
+ fix wrong test setup
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/health_check_controller_spec.rb15
-rw-r--r--spec/controllers/health_controller_spec.rb6
2 files changed, 19 insertions, 2 deletions
diff --git a/spec/controllers/health_check_controller_spec.rb b/spec/controllers/health_check_controller_spec.rb
index 6c545169450..e7abe1ba78d 100644
--- a/spec/controllers/health_check_controller_spec.rb
+++ b/spec/controllers/health_check_controller_spec.rb
@@ -10,7 +10,7 @@ describe HealthCheckController do
let(:not_whitelisted_ip) { '127.0.0.2' }
before do
- allow(Settings.monitoring).to receive(:ip_whitelist).and_return([IPAddr.new(whitelisted_ip)])
+ allow(Settings.monitoring).to receive(:ip_whitelist).and_return([whitelisted_ip])
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
end
@@ -22,19 +22,23 @@ describe HealthCheckController do
it 'returns a not found page' do
get :index
+
expect(response).to be_not_found
end
context 'when services are accessed with token' do
it 'supports passing the token in the header' do
request.headers['TOKEN'] = token
+
get :index
+
expect(response).to be_success
expect(response.content_type).to eq 'text/plain'
end
it 'supports successful plaintest response' do
get :index, token: token
+
expect(response).to be_success
expect(response.content_type).to eq 'text/plain'
end
@@ -50,12 +54,14 @@ describe HealthCheckController do
it 'supports successful plaintest response' do
get :index
+
expect(response).to be_success
expect(response.content_type).to eq 'text/plain'
end
it 'supports successful json response' do
get :index, format: :json
+
expect(response).to be_success
expect(response.content_type).to eq 'application/json'
expect(json_response['healthy']).to be true
@@ -63,6 +69,7 @@ describe HealthCheckController do
it 'supports successful xml response' do
get :index, format: :xml
+
expect(response).to be_success
expect(response.content_type).to eq 'application/xml'
expect(xml_response['healthy']).to be true
@@ -70,6 +77,7 @@ describe HealthCheckController do
it 'supports successful responses for specific checks' do
get :index, checks: 'email', format: :json
+
expect(response).to be_success
expect(response.content_type).to eq 'application/json'
expect(json_response['healthy']).to be true
@@ -79,6 +87,7 @@ describe HealthCheckController do
context 'when a service is down but NO access token' do
it 'returns a not found page' do
get :index
+
expect(response).to be_not_found
end
end
@@ -92,6 +101,7 @@ describe HealthCheckController do
it 'supports failure plaintest response' do
get :index
+
expect(response).to have_http_status(500)
expect(response.content_type).to eq 'text/plain'
expect(response.body).to include('The server is on fire')
@@ -99,6 +109,7 @@ describe HealthCheckController do
it 'supports failure json response' do
get :index, format: :json
+
expect(response).to have_http_status(500)
expect(response.content_type).to eq 'application/json'
expect(json_response['healthy']).to be false
@@ -107,6 +118,7 @@ describe HealthCheckController do
it 'supports failure xml response' do
get :index, format: :xml
+
expect(response).to have_http_status(500)
expect(response.content_type).to eq 'application/xml'
expect(xml_response['healthy']).to be false
@@ -115,6 +127,7 @@ describe HealthCheckController do
it 'supports failure responses for specific checks' do
get :index, checks: 'email', format: :json
+
expect(response).to have_http_status(500)
expect(response.content_type).to eq 'application/json'
expect(json_response['healthy']).to be false
diff --git a/spec/controllers/health_controller_spec.rb b/spec/controllers/health_controller_spec.rb
index 3e4370652d0..4b22155a431 100644
--- a/spec/controllers/health_controller_spec.rb
+++ b/spec/controllers/health_controller_spec.rb
@@ -8,7 +8,7 @@ describe HealthController do
let(:not_whitelisted_ip) { '127.0.0.2' }
before do
- allow(Settings.monitoring).to receive(:ip_whitelist).and_return([IPAddr.new(whitelisted_ip)])
+ allow(Settings.monitoring).to receive(:ip_whitelist).and_return([whitelisted_ip])
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
end
@@ -20,6 +20,7 @@ describe HealthController do
it 'returns proper response' do
get :readiness
+
expect(json_response['db_check']['status']).to eq('ok')
expect(json_response['redis_check']['status']).to eq('ok')
expect(json_response['fs_shards_check']['status']).to eq('ok')
@@ -34,6 +35,7 @@ describe HealthController do
it 'returns proper response' do
get :readiness
+
expect(response.status).to eq(404)
end
end
@@ -47,6 +49,7 @@ describe HealthController do
it 'returns proper response' do
get :liveness
+
expect(json_response['db_check']['status']).to eq('ok')
expect(json_response['redis_check']['status']).to eq('ok')
expect(json_response['fs_shards_check']['status']).to eq('ok')
@@ -60,6 +63,7 @@ describe HealthController do
it 'returns proper response' do
get :liveness
+
expect(response.status).to eq(404)
end
end