diff options
Diffstat (limited to 'spec/factories/ci/pipelines.rb')
-rw-r--r-- | spec/factories/ci/pipelines.rb | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/spec/factories/ci/pipelines.rb b/spec/factories/ci/pipelines.rb index 6174bfbfbb7..4fa5dde4eff 100644 --- a/spec/factories/ci/pipelines.rb +++ b/spec/factories/ci/pipelines.rb @@ -15,15 +15,31 @@ FactoryBot.define do # on pipeline factories to avoid circular references transient { head_pipeline_of { nil } } + transient { child_of { nil } } + + after(:build) do |pipeline, evaluator| + if evaluator.child_of + pipeline.project = evaluator.child_of.project + pipeline.source = :parent_pipeline + end + end + after(:create) do |pipeline, evaluator| merge_request = evaluator.head_pipeline_of merge_request&.update!(head_pipeline: pipeline) + + if evaluator.child_of + bridge = create(:ci_bridge, pipeline: evaluator.child_of) + create(:ci_sources_pipeline, + source_job: bridge, + pipeline: pipeline) + end end factory :ci_pipeline do transient { ci_ref_presence { true } } - after(:build) do |pipeline, evaluator| + before(:create) do |pipeline, evaluator| pipeline.ensure_ci_ref! if evaluator.ci_ref_presence && pipeline.ci_ref_id.nil? end |