Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-04-13 12:11:10 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-04-13 12:11:10 +0300
commit37974ac0b196b06ffcc6cbea44385eaac1cc57bd (patch)
tree98450a46516f93a71018ec6b8d718fc023744575 /spec/lib/gitlab/analytics
parentfcbd3db20f5dfb13ae33ddfee98be8d92cade72f (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/analytics')
-rw-r--r--spec/lib/gitlab/analytics/cycle_analytics/records_fetcher_spec.rb43
1 files changed, 39 insertions, 4 deletions
diff --git a/spec/lib/gitlab/analytics/cycle_analytics/records_fetcher_spec.rb b/spec/lib/gitlab/analytics/cycle_analytics/records_fetcher_spec.rb
index ef0ac2557b4..ebc5ae2a632 100644
--- a/spec/lib/gitlab/analytics/cycle_analytics/records_fetcher_spec.rb
+++ b/spec/lib/gitlab/analytics/cycle_analytics/records_fetcher_spec.rb
@@ -7,16 +7,15 @@ RSpec.describe Gitlab::Analytics::CycleAnalytics::RecordsFetcher do
Timecop.freeze { example.run }
end
+ let(:params) { { from: 1.year.ago, current_user: user } }
+
let_it_be(:project) { create(:project, :empty_repo) }
let_it_be(:user) { create(:user) }
subject do
Gitlab::Analytics::CycleAnalytics::DataCollector.new(
stage: stage,
- params: {
- from: 1.year.ago,
- current_user: user
- }
+ params: params
).records_fetcher.serialized_records
end
@@ -131,4 +130,40 @@ RSpec.describe Gitlab::Analytics::CycleAnalytics::RecordsFetcher do
end
end
end
+
+ describe 'pagination' do
+ let_it_be(:issue1) { create(:issue, project: project) }
+ let_it_be(:issue2) { create(:issue, project: project) }
+ let_it_be(:issue3) { create(:issue, project: project) }
+
+ let(:stage) do
+ build(:cycle_analytics_project_stage, {
+ start_event_identifier: :plan_stage_start,
+ end_event_identifier: :issue_first_mentioned_in_commit,
+ project: project
+ })
+ end
+
+ before(:all) do
+ issue1.metrics.update(first_added_to_board_at: 3.days.ago, first_mentioned_in_commit_at: 2.days.ago)
+ issue2.metrics.update(first_added_to_board_at: 3.days.ago, first_mentioned_in_commit_at: 2.days.ago)
+ issue3.metrics.update(first_added_to_board_at: 3.days.ago, first_mentioned_in_commit_at: 2.days.ago)
+ end
+
+ before do
+ project.add_user(user, Gitlab::Access::DEVELOPER)
+
+ stub_const('Gitlab::Analytics::CycleAnalytics::RecordsFetcher::MAX_RECORDS', 2)
+ end
+
+ it 'limits the results' do
+ expect(subject.size).to eq(2)
+ end
+
+ it 'loads the record for the next page' do
+ params[:page] = 2
+
+ expect(subject.size).to eq(1)
+ end
+ end
end