summaryrefslogtreecommitdiff
path: root/spec/factories/ci/bridge.rb
blob: b1d82b9841198d45f8ff87c262627a5c43b1749c (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
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 :success

    pipeline factory: :ci_pipeline

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

    transient { downstream nil }

    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
    end
  end
end