Commit ad2c9e65 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Apply fix from @ahegyi

Checks if the project id param is available
parent 8ac27d4f
......@@ -21,11 +21,9 @@ module Analytics
private
def group_params
{
created_after: request_params.created_after,
created_before: request_params.created_before,
project_ids: request_params.project_ids
}
hash = { created_after: request_params.created_after, created_before: request_params.created_before }
hash[:project_ids] = request_params.project_ids if request_params.project_ids.any?
hash
end
def validate_params
......
......@@ -25,6 +25,24 @@ describe Analytics::CycleAnalytics::SummaryController do
expect(response).to match_response_schema('analytics/cycle_analytics/summary', dir: 'ee')
end
it 'omits `projects` parameter if it is not given' do
expect(CycleAnalytics::GroupLevel).to receive(:new).with(group: group, options: hash_excluding(:projects)).and_call_original
subject
expect(response).to be_successful
end
it 'contains `projects` parameter' do
params[:project_ids] = [-1]
expect(CycleAnalytics::GroupLevel).to receive(:new).with(group: group, options: hash_including(:projects)).and_call_original
subject
expect(response).to be_successful
end
include_examples 'cycle analytics data endpoint examples'
include_examples 'group permission check on the controller level'
end
......
......@@ -180,6 +180,8 @@ describe 'Analytics (JavaScript fixtures)', :sidekiq_inline do
stub_feature_flags(Gitlab::Analytics::CYCLE_ANALYTICS_FEATURE_FLAG => true)
stub_licensed_features(cycle_analytics_for_groups: true)
prepare_cycle_analytics_data
sign_in(user)
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