diff options
-rw-r--r-- | app/controllers/projects/environments_controller.rb | 1 | ||||
-rw-r--r-- | spec/controllers/projects/environments_controller_spec.rb | 22 |
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 |