diff options
Diffstat (limited to 'spec/controllers/projects/analytics')
-rw-r--r-- | spec/controllers/projects/analytics/cycle_analytics/summary_controller_spec.rb | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/spec/controllers/projects/analytics/cycle_analytics/summary_controller_spec.rb b/spec/controllers/projects/analytics/cycle_analytics/summary_controller_spec.rb index 1832b84ab6e..a366b2583d4 100644 --- a/spec/controllers/projects/analytics/cycle_analytics/summary_controller_spec.rb +++ b/spec/controllers/projects/analytics/cycle_analytics/summary_controller_spec.rb @@ -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 |