blob: f92e213a3858e70b1e058650da422b72bdb05905 (
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# frozen_string_literal: true
FactoryBot.define do
factory :deployment, class: 'Deployment' do
sha { 'b83d6e391c22777fca1ed3012fce84f633d7fed0' }
ref { 'master' }
tag { false }
user { nil }
project { nil }
deployable factory: :ci_build
environment factory: :environment
after(:build) do |deployment, evaluator|
deployment.project ||= deployment.environment.project
deployment.user ||= deployment.project.creator
unless deployment.project.repository_exists?
allow(deployment.project.repository).to receive(:create_ref)
end
if deployment.cluster && deployment.cluster.project_type? && deployment.cluster.project.nil?
deployment.cluster.projects << deployment.project
end
end
trait :review_app do
sha { TestEnv::BRANCH_SHA['pages-deploy'] }
ref { 'pages-deploy' }
end
trait :on_cluster do
cluster factory: %i(cluster provided_by_gcp)
end
trait :running do
status { :running }
end
trait :success do
status { :success }
finished_at { Time.now }
end
trait :failed do
status { :failed }
finished_at { Time.now }
end
trait :canceled do
status { :canceled }
finished_at { Time.now }
end
trait :created do
status { :created }
end
# This trait hooks the state maechine's events
trait :succeed do
after(:create) do |deployment, evaluator|
deployment.succeed!
end
end
end
end
|