Welcome to mirror list, hosted at ThFree Co, Russian Federation.

bridge.rb « ci « factories « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: bacf163896cfd42ff063b0adfd926de2278c12d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# frozen_string_literal: true

FactoryBot.define do
  factory :ci_bridge, class: 'Ci::Bridge' do
    name { 'bridge' }
    stage { 'test' }
    stage_idx { 0 }
    ref { 'master' }
    tag { false }
    created_at { 'Di 29. Okt 09:50:00 CET 2013' }
    status { :created }
    scheduling_type { 'stage' }

    pipeline factory: :ci_pipeline

    trait :variables do
      yaml_variables do
        [{ key: 'BRIDGE', value: 'cross', public: true }]
      end
    end

    transient do
      downstream { nil }
      upstream { nil }
    end

    after(:build) do |bridge, evaluator|
      bridge.project ||= bridge.pipeline.project

      if evaluator.downstream.present?
        bridge.options = bridge.options.to_h.merge(
          trigger: { project: evaluator.downstream.full_path }
        )
      end

      if evaluator.upstream.present?
        bridge.options = bridge.options.to_h.merge(
          bridge_needs: { pipeline: evaluator.upstream.full_path }
        )
      end
    end
  end
end