diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2019-04-28 14:53:12 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzegorz@gitlab.com> | 2019-04-28 14:53:12 +0300 |
commit | 536d96a3e02daceca8398745cd27ab1e0f56711d (patch) | |
tree | 70c395ae775a7f56352aa88aaec9bd5810a555f3 /spec/controllers | |
parent | ddee4426c4bd3df8bde7936a6ffb0a1973a4d5a1 (diff) | |
parent | 0e093940e1135897b996a5f16239eca62cc6089e (diff) |
Merge branch '60383-setup-dashboard-endpoint' into 'master'
Create dashboards endpoint & setup dashboard post-processing
Closes #60383
See merge request gitlab-org/gitlab-ce!27405
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/projects/environments_controller_spec.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/controllers/projects/environments_controller_spec.rb b/spec/controllers/projects/environments_controller_spec.rb index 75158f2e8e0..c1c4be45168 100644 --- a/spec/controllers/projects/environments_controller_spec.rb +++ b/spec/controllers/projects/environments_controller_spec.rb @@ -461,6 +461,43 @@ describe Projects::EnvironmentsController do end end + describe 'metrics_dashboard' do + context 'when prometheus endpoint is disabled' do + before do + stub_feature_flags(environment_metrics_use_prometheus_endpoint: false) + end + + it 'responds with status code 403' do + get :metrics_dashboard, params: environment_params(format: :json) + + expect(response).to have_gitlab_http_status(:forbidden) + end + end + + context 'when prometheus endpoint is enabled' do + it 'returns a json representation of the environment dashboard' do + get :metrics_dashboard, params: environment_params(format: :json) + + expect(response).to have_gitlab_http_status(:ok) + expect(json_response.keys).to contain_exactly('dashboard', 'status') + expect(json_response['dashboard']).to be_an_instance_of(Hash) + end + + context 'when the dashboard could not be provided' do + before do + allow(YAML).to receive(:safe_load).and_return({}) + end + + it 'returns an error response' do + get :metrics_dashboard, params: environment_params(format: :json) + + expect(response).to have_gitlab_http_status(:unprocessable_entity) + expect(json_response.keys).to contain_exactly('message', 'status', 'http_status') + end + end + end + end + describe 'GET #search' do before do create(:environment, name: 'staging', project: project) |