debian-mirror-gitlab/spec/factories/deployments.rb
2019-07-31 17:26:46 +00:00

51 lines
1.1 KiB
Ruby

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
end
trait :review_app do
sha { TestEnv::BRANCH_SHA['pages-deploy'] }
ref 'pages-deploy'
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
# This trait hooks the state maechine's events
trait :succeed do
after(:create) do |deployment, evaluator|
deployment.succeed!
end
end
end
end