summaryrefslogtreecommitdiff
path: root/spec/factories
diff options
context:
space:
mode:
Diffstat (limited to 'spec/factories')
-rw-r--r--spec/factories/ci/pipelines.rb24
-rw-r--r--spec/factories/merge_requests.rb22
2 files changed, 29 insertions, 17 deletions
diff --git a/spec/factories/ci/pipelines.rb b/spec/factories/ci/pipelines.rb
index 11686ed5277..f2c342f76d0 100644
--- a/spec/factories/ci/pipelines.rb
+++ b/spec/factories/ci/pipelines.rb
@@ -99,6 +99,30 @@ FactoryBot.define do
trait :repository_source do
config_source { Ci::Pipeline.config_sources[:repository_source] }
end
+
+ trait :detached_merge_request_pipeline do
+ merge_request
+
+ source { :merge_request_event }
+ project { merge_request.source_project }
+ sha { merge_request.source_branch_sha }
+ ref { merge_request.ref_path }
+ end
+
+ trait :legacy_detached_merge_request_pipeline do
+ detached_merge_request_pipeline
+
+ ref { merge_request.source_branch }
+ end
+
+ trait :merged_result_pipeline do
+ detached_merge_request_pipeline
+
+ sha { 'test-merge-sha'}
+ ref { merge_request.merge_ref_path }
+ source_sha { merge_request.source_branch_sha }
+ target_sha { merge_request.target_branch_sha }
+ end
end
end
end
diff --git a/spec/factories/merge_requests.rb b/spec/factories/merge_requests.rb
index f717bab5f2a..08a8ede61b1 100644
--- a/spec/factories/merge_requests.rb
+++ b/spec/factories/merge_requests.rb
@@ -147,23 +147,13 @@ FactoryBot.define do
trait :with_legacy_detached_merge_request_pipeline do
after(:create) do |merge_request|
- merge_request.pipelines_for_merge_request << create(:ci_pipeline,
- source: :merge_request_event,
- merge_request: merge_request,
- project: merge_request.source_project,
- ref: merge_request.source_branch,
- sha: merge_request.source_branch_sha)
+ create(:ci_pipeline, :legacy_detached_merge_request_pipeline, merge_request: merge_request)
end
end
trait :with_detached_merge_request_pipeline do
after(:create) do |merge_request|
- merge_request.pipelines_for_merge_request << create(:ci_pipeline,
- source: :merge_request_event,
- merge_request: merge_request,
- project: merge_request.source_project,
- ref: merge_request.ref_path,
- sha: merge_request.source_branch_sha)
+ create(:ci_pipeline, :detached_merge_request_pipeline, merge_request: merge_request)
end
end
@@ -175,14 +165,12 @@ FactoryBot.define do
end
after(:create) do |merge_request, evaluator|
- merge_request.pipelines_for_merge_request << create(:ci_pipeline,
- source: :merge_request_event,
+ create(:ci_pipeline, :merged_result_pipeline,
merge_request: merge_request,
- project: merge_request.source_project,
- ref: merge_request.merge_ref_path,
sha: evaluator.merge_sha,
source_sha: evaluator.source_sha,
- target_sha: evaluator.target_sha)
+ target_sha: evaluator.target_sha
+ )
end
end