debian-mirror-gitlab/spec/factories/deployments.rb

66 lines
1.6 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
FactoryBot.define do
2020-03-13 15:44:24 +05:30
factory :deployment, class: 'Deployment' do
2019-12-21 20:55:43 +05:30
sha { 'b83d6e391c22777fca1ed3012fce84f633d7fed0' }
ref { 'master' }
tag { false }
user { nil }
project { nil }
2020-04-08 14:13:33 +05:30
deployable { association :ci_build, environment: environment.name, project: environment.project }
environment factory: :environment
after(:build) do |deployment, evaluator|
2016-09-29 09:46:39 +05:30
deployment.project ||= deployment.environment.project
2018-03-17 18:26:18 +05:30
deployment.user ||= deployment.project.creator
unless deployment.project.repository_exists?
allow(deployment.project.repository).to receive(:create_ref)
end
2019-12-04 20:38:33 +05:30
if deployment.cluster && deployment.cluster.project_type? && deployment.cluster.project.nil?
deployment.cluster.projects << deployment.project
end
end
2018-12-13 13:39:08 +05:30
trait :review_app do
sha { TestEnv::BRANCH_SHA['pages-deploy'] }
2019-12-21 20:55:43 +05:30
ref { 'pages-deploy' }
2018-12-13 13:39:08 +05:30
end
2019-09-30 21:07:59 +05:30
trait :on_cluster do
cluster factory: %i(cluster provided_by_gcp)
end
2018-12-13 13:39:08 +05:30
trait :running do
2019-12-21 20:55:43 +05:30
status { :running }
2018-12-13 13:39:08 +05:30
end
trait :success do
2019-12-21 20:55:43 +05:30
status { :success }
2018-12-13 13:39:08 +05:30
finished_at { Time.now }
end
trait :failed do
2019-12-21 20:55:43 +05:30
status { :failed }
2018-12-13 13:39:08 +05:30
finished_at { Time.now }
end
trait :canceled do
2019-12-21 20:55:43 +05:30
status { :canceled }
2018-12-13 13:39:08 +05:30
finished_at { Time.now }
end
2019-12-26 22:10:19 +05:30
trait :created do
status { :created }
end
2018-12-13 13:39:08 +05:30
# This trait hooks the state maechine's events
trait :succeed do
after(:create) do |deployment, evaluator|
deployment.succeed!
end
end
end
end