Commit 4a2b51b4 authored by Shinya Maeda's avatar Shinya Maeda

Merge branch 'mr-pipeline-factory-traits' into 'master'

Ci::Pipeline factories for the various kinds of merge request pipelines

See merge request gitlab-org/gitlab!27951
parents 4944db99 0c4567c0
......@@ -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
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment