Commit 22f8368b authored by Jan Provaznik's avatar Jan Provaznik

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
parents 47f5d0cf ec399e65
......@@ -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
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment