summaryrefslogtreecommitdiff
path: root/spec/factories
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-07-08 09:09:17 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-07-08 09:09:17 +0000
commit21341457a8c422d890a9ec30838b597dea565d62 (patch)
treeaa8aca2a9bce4e16936cc8d7b40aa1c79ca82e35 /spec/factories
parent0a319374e7784aa5c2d1c30dd832d2a0509edbab (diff)
downloadgitlab-ce-21341457a8c422d890a9ec30838b597dea565d62.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/factories')
-rw-r--r--spec/factories/snippet_statistics.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/factories/snippet_statistics.rb b/spec/factories/snippet_statistics.rb
new file mode 100644
index 00000000000..ab2d9525466
--- /dev/null
+++ b/spec/factories/snippet_statistics.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :snippet_statistics do
+ snippet
+
+ initialize_with do
+ # statistics are automatically created when a snippet is created
+ snippet&.statistics || new
+ end
+
+ transient do
+ with_data { false }
+ size_multiplier { 1 }
+ end
+
+ after(:build) do |snippet_statistics, evaluator|
+ if evaluator.with_data
+ snippet_statistics.repository_size = evaluator.size_multiplier
+ snippet_statistics.commit_count = evaluator.size_multiplier * 2
+ snippet_statistics.file_count = evaluator.size_multiplier * 3
+ end
+ end
+ end
+end