summaryrefslogtreecommitdiff
path: root/spec/support
diff options
context:
space:
mode:
authorTiago Botelho <tiagonbotelho@hotmail.com>2018-02-15 13:23:39 +0000
committerTiago Botelho <tiagonbotelho@hotmail.com>2018-02-28 10:46:20 +0000
commit335ee79a73fafdf00fac6e8ffc286ce4bad273ff (patch)
treed30033fd007c992448ce02f42e46f9da48e223cb /spec/support
parent3f31da9c69c550d1698a1376e37d36f4e6e309b5 (diff)
downloadgitlab-ce-335ee79a73fafdf00fac6e8ffc286ce4bad273ff.tar.gz
Refactors median code to work with both single and multiple projects
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/cycle_analytics_helpers.rb12
-rw-r--r--spec/support/cycle_analytics_helpers/test_generation.rb2
2 files changed, 13 insertions, 1 deletions
diff --git a/spec/support/cycle_analytics_helpers.rb b/spec/support/cycle_analytics_helpers.rb
index d5ef80cfab2..7440894f1f4 100644
--- a/spec/support/cycle_analytics_helpers.rb
+++ b/spec/support/cycle_analytics_helpers.rb
@@ -26,6 +26,18 @@ module CycleAnalyticsHelpers
ref: 'refs/heads/master').execute
end
+ def create_cycle(user, project, issue, mr, milestone, pipeline)
+ issue.update(milestone: milestone)
+ pipeline.run
+
+ ci_build = create(:ci_build, pipeline: pipeline, status: :success, author: user)
+
+ merge_merge_requests_closing_issue(issue)
+ ProcessCommitWorker.new.perform(project.id, user.id, mr.commits.last.to_hash)
+
+ ci_build
+ end
+
def create_merge_request_closing_issue(issue, message: nil, source_branch: nil, commit_message: 'commit message')
if !source_branch || project.repository.commit(source_branch).blank?
source_branch = generate(:branch)
diff --git a/spec/support/cycle_analytics_helpers/test_generation.rb b/spec/support/cycle_analytics_helpers/test_generation.rb
index da501a5077a..19b32c84d81 100644
--- a/spec/support/cycle_analytics_helpers/test_generation.rb
+++ b/spec/support/cycle_analytics_helpers/test_generation.rb
@@ -50,7 +50,7 @@ module CycleAnalyticsHelpers
end
median_time_difference = time_differences.sort[2]
- expect(subject[phase].median.presence).to be_within(5).of(median_time_difference)
+ expect(subject[phase].median).to be_within(5).of(median_time_difference)
end
context "when the data belongs to another project" do