2016-06-16 23:09:34 +05:30
|
|
|
FactoryGirl.define do
|
|
|
|
factory :environment, class: Environment do
|
|
|
|
sequence(:name) { |n| "environment#{n}" }
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
association :project, :repository
|
2016-09-13 17:45:13 +05:30
|
|
|
sequence(:external_url) { |n| "https://env#{n}.example.gitlab.com" }
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
trait :with_review_app do |environment|
|
|
|
|
transient do
|
|
|
|
ref 'master'
|
|
|
|
end
|
|
|
|
|
|
|
|
# At this point `review app` is an ephemeral concept related to
|
|
|
|
# deployments being deployed for given environment. There is no
|
|
|
|
# first-class `review app` available so we need to create set of
|
|
|
|
# interconnected objects to simulate a review app.
|
|
|
|
#
|
|
|
|
after(:create) do |environment, evaluator|
|
|
|
|
pipeline = create(:ci_pipeline, project: environment.project)
|
|
|
|
|
|
|
|
deployable = create(:ci_build, name: "#{environment.name}:deploy",
|
|
|
|
pipeline: pipeline)
|
|
|
|
|
|
|
|
deployment = create(:deployment,
|
|
|
|
environment: environment,
|
|
|
|
project: environment.project,
|
|
|
|
deployable: deployable,
|
|
|
|
ref: evaluator.ref,
|
|
|
|
sha: environment.project.commit(evaluator.ref).id)
|
|
|
|
|
|
|
|
teardown_build = create(:ci_build, :manual,
|
|
|
|
name: "#{environment.name}:teardown",
|
|
|
|
pipeline: pipeline)
|
|
|
|
|
|
|
|
deployment.update_column(:on_stop, teardown_build.name)
|
|
|
|
environment.update_attribute(:deployments, [deployment])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :non_playable do
|
|
|
|
status 'created'
|
|
|
|
self.when 'manual'
|
|
|
|
end
|
2016-06-16 23:09:34 +05:30
|
|
|
end
|
|
|
|
end
|