summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Provaznik <jprovaznik@gitlab.com>2019-05-20 15:04:05 +0000
committerJan Provaznik <jprovaznik@gitlab.com>2019-05-20 15:04:05 +0000
commit22f8368becb94afbd07b549f677a0e2b1354c2d1 (patch)
tree5aee95f241456b105f6cd9a20606de21edec1bb3
parent47f5d0cfcfcd5dbbc94ff674d682908c475eca08 (diff)
parentec399e6565370a7a7fcabac2d851489fc83d8e72 (diff)
downloadgitlab-ce-22f8368becb94afbd07b549f677a0e2b1354c2d1.tar.gz
Merge branch '59313-mandatory-window-params' into 'master'
Require time window params in metrics dashboard Closes #59313 See merge request gitlab-org/gitlab-ce!28194
-rw-r--r--app/controllers/projects/environments_controller.rb1
-rw-r--r--spec/controllers/projects/environments_controller_spec.rb22
2 files changed, 10 insertions, 13 deletions
diff --git a/app/controllers/projects/environments_controller.rb b/app/controllers/projects/environments_controller.rb
index 5a4adea497b..c342e1c80b0 100644
--- a/app/controllers/projects/environments_controller.rb
+++ b/app/controllers/projects/environments_controller.rb
@@ -221,7 +221,6 @@ class Projects::EnvironmentsController < Projects::ApplicationController
def metrics_params
return unless Feature.enabled?(:metrics_time_window, project)
- return unless params[:start].present? || params[:end].present?
params.require([:start, :end])
end
diff --git a/spec/controllers/projects/environments_controller_spec.rb b/spec/controllers/projects/environments_controller_spec.rb
index cf23d937037..d5eea5b0439 100644
--- a/spec/controllers/projects/environments_controller_spec.rb
+++ b/spec/controllers/projects/environments_controller_spec.rb
@@ -383,6 +383,8 @@ describe Projects::EnvironmentsController do
end
describe 'GET #additional_metrics' do
+ let(:window_params) { { start: '1554702993.5398998', end: '1554717396.996232' } }
+
before do
allow(controller).to receive(:environment).and_return(environment)
end
@@ -394,7 +396,7 @@ describe Projects::EnvironmentsController do
context 'when requesting metrics as JSON' do
it 'returns a metrics JSON document' do
- additional_metrics
+ additional_metrics(window_params)
expect(response).to have_gitlab_http_status(204)
expect(json_response).to eq({})
@@ -414,23 +416,19 @@ describe Projects::EnvironmentsController do
end
it 'returns a metrics JSON document' do
- additional_metrics
+ additional_metrics(window_params)
expect(response).to be_ok
expect(json_response['success']).to be(true)
expect(json_response['data']).to eq({})
expect(json_response['last_update']).to eq(42)
end
+ end
- context 'when time params are provided' do
- it 'returns a metrics JSON document' do
- additional_metrics(start: '1554702993.5398998', end: '1554717396.996232')
-
- expect(response).to be_ok
- expect(json_response['success']).to be(true)
- expect(json_response['data']).to eq({})
- expect(json_response['last_update']).to eq(42)
- end
+ context 'when time params are missing' do
+ it 'raises an error when window params are missing' do
+ expect { additional_metrics }
+ .to raise_error(ActionController::ParameterMissing)
end
end
@@ -450,7 +448,7 @@ describe Projects::EnvironmentsController do
end
it 'raises an error when start is missing' do
- expect { additional_metrics(start: '1552647300.651094') }
+ expect { additional_metrics(end: '1552647300.651094') }
.to raise_error(ActionController::ParameterMissing)
end