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
path: root/spec
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2016-09-27 14:29:56 +0300
committerRuben Davila <rdavila84@gmail.com>2016-09-28 18:37:53 +0300
commit16518f6a377385c1d635049ba9601cd7ed2a68bc (patch)
treeb8756a277c5f74e09bd72edccc60596f0668f428 /spec
parent57837fd1ca96532e8e2ac0f3260dc3c028aebbb0 (diff)
Merge branch '22578-cycle-analytics-incorrect-commit-count'
Diffstat (limited to 'spec')
-rw-r--r--spec/models/cycle_analytics/summary_spec.rb6
-rw-r--r--spec/support/cycle_analytics_helpers.rb26
2 files changed, 21 insertions, 11 deletions
diff --git a/spec/models/cycle_analytics/summary_spec.rb b/spec/models/cycle_analytics/summary_spec.rb
index 743bc2da33f..9d67bc82cba 100644
--- a/spec/models/cycle_analytics/summary_spec.rb
+++ b/spec/models/cycle_analytics/summary_spec.rb
@@ -34,6 +34,12 @@ describe CycleAnalytics::Summary, models: true do
expect(subject.commits).to eq(0)
end
+
+ it "finds a large (> 100) snumber of commits if present" do
+ Timecop.freeze(5.days.from_now) { create_commit("Test message", project, user, 'master', count: 100) }
+
+ expect(subject.commits).to eq(100)
+ end
end
describe "#deploys" do
diff --git a/spec/support/cycle_analytics_helpers.rb b/spec/support/cycle_analytics_helpers.rb
index e8e760a6187..62a5b46d47b 100644
--- a/spec/support/cycle_analytics_helpers.rb
+++ b/spec/support/cycle_analytics_helpers.rb
@@ -4,24 +4,28 @@ module CycleAnalyticsHelpers
create_commit("Commit for ##{issue.iid}", issue.project, user, branch_name)
end
- def create_commit(message, project, user, branch_name)
- filename = random_git_name
+ def create_commit(message, project, user, branch_name, count: 1)
oldrev = project.repository.commit(branch_name).sha
+ commit_shas = Array.new(count) do |index|
+ filename = random_git_name
- options = {
- committer: project.repository.user_to_committer(user),
- author: project.repository.user_to_committer(user),
- commit: { message: message, branch: branch_name, update_ref: true },
- file: { content: "content", path: filename, update: false }
- }
+ options = {
+ committer: project.repository.user_to_committer(user),
+ author: project.repository.user_to_committer(user),
+ commit: { message: message, branch: branch_name, update_ref: true },
+ file: { content: "content", path: filename, update: false }
+ }
+
+ commit_sha = Gitlab::Git::Blob.commit(project.repository, options)
+ project.repository.commit(commit_sha)
- commit_sha = Gitlab::Git::Blob.commit(project.repository, options)
- project.repository.commit(commit_sha)
+ commit_sha
+ end
GitPushService.new(project,
user,
oldrev: oldrev,
- newrev: commit_sha,
+ newrev: commit_shas.last,
ref: 'refs/heads/master').execute
end