Commit 2bb71363 authored by Adam Hegyi's avatar Adam Hegyi

Move Project-level VSA record filtering into FOSS

This change alters the summary endpoint of the Project-level Value
Stream Analytics to allow filtering similarly to the group-level VSA
endpoints.
parent 8274b874
......@@ -20,7 +20,7 @@ class Projects::Analytics::CycleAnalytics::SummaryController < Projects::Applica
end
def allowed_params
params.permit(:created_after, :created_before)
request_params.to_data_collector_params
end
end
......
......@@ -11,13 +11,4 @@ module EE::Projects::Analytics::CycleAnalytics::SummaryController
render_404
end
end
private
override :allowed_params
def allowed_params
return super unless project.licensed_feature_available?(:cycle_analytics_for_projects)
request_params.to_data_collector_params
end
end
......@@ -5,10 +5,6 @@ require 'spec_helper'
RSpec.describe Projects::Analytics::CycleAnalytics::SummaryController do
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project) }
let_it_be(:author) { create(:user) }
let_it_be(:issue_with_author) { create(:issue, project: project, author: author, created_at: Date.new(2015, 1, 1)) }
let_it_be(:issue_with_other_author) { create(:issue, project: project, author: user, created_at: Date.new(2015, 1, 1)) }
let(:params) { { namespace_id: project.namespace.to_param, project_id: project.to_param, created_after: '2010-01-01', created_before: '2020-01-02' } }
......@@ -16,42 +12,6 @@ RSpec.describe Projects::Analytics::CycleAnalytics::SummaryController do
sign_in(user)
end
describe 'GET "show"' do
subject { get :show, params: params }
before do
params[:author_username] = issue_with_author.author.username
project.add_reporter(user)
end
context 'when cycle_analytics_for_projects feature is available' do
before do
stub_licensed_features(cycle_analytics_for_projects: true)
end
it 'filters by author username' do
subject
expect(response).to be_successful
issue_count = json_response.first
expect(issue_count['value']).to eq('1')
end
end
context 'when cycle_analytics_for_projects feature is not available' do
it 'does not apply the filter' do
subject
expect(response).to be_successful
issue_count = json_response.first
expect(issue_count['value']).to eq('2')
end
end
end
describe 'GET "time_summary"' do
let_it_be(:first_mentioned_in_commit_at) { Date.new(2015, 1, 1) }
let_it_be(:closed_at) { Date.new(2015, 2, 1) }
......
......@@ -6,7 +6,7 @@ RSpec.describe Projects::Analytics::CycleAnalytics::SummaryController do
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project) }
let(:params) { { namespace_id: project.namespace.to_param, project_id: project.to_param, created_after: '2010-01-01', created_before: '2010-01-02' } }
let(:params) { { namespace_id: project.namespace.to_param, project_id: project.to_param, created_after: '2010-01-01', created_before: '2010-02-01' } }
before do
sign_in(user)
......@@ -42,5 +42,39 @@ RSpec.describe Projects::Analytics::CycleAnalytics::SummaryController do
expect(response).to have_gitlab_http_status(:not_found)
end
end
context 'when filters are applied' do
let_it_be(:author) { create(:user) }
let_it_be(:milestone) { create(:milestone, title: 'milestone 1', project: project) }
let_it_be(:issue_with_author) { create(:issue, project: project, author: author, created_at: Date.new(2010, 1, 15)) }
let_it_be(:issue_with_other_author) { create(:issue, project: project, author: user, created_at: Date.new(2010, 1, 15)) }
let_it_be(:issue_with_milestone) { create(:issue, project: project, milestone: milestone, created_at: Date.new(2010, 1, 15)) }
before do
project.add_reporter(user)
end
it 'filters by author username' do
params[:author_username] = author.username
subject
expect(response).to be_successful
issue_count = json_response.first
expect(issue_count['value']).to eq('1')
end
it 'filters by milestone title' do
params[:milestone_title] = milestone.title
subject
expect(response).to be_successful
issue_count = json_response.first
expect(issue_count['value']).to eq('1')
end
end
end
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