2016-06-14 11:51:12 +00:00
|
|
|
FactoryGirl.define do
|
|
|
|
factory :environment, class: Environment do
|
|
|
|
sequence(:name) { |n| "environment#{n}" }
|
|
|
|
|
|
|
|
project factory: :empty_project
|
2016-07-26 07:35:47 +00:00
|
|
|
sequence(:external_url) { |n| "https://env#{n}.example.gitlab.com" }
|
2016-11-09 08:42:09 +00:00
|
|
|
|
|
|
|
trait :with_review_app do |environment|
|
|
|
|
project
|
|
|
|
|
|
|
|
# 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|
|
|
|
|
deployment = create(:deployment,
|
|
|
|
environment: environment,
|
|
|
|
project: environment.project,
|
|
|
|
sha: environment.project.commit.id)
|
|
|
|
|
|
|
|
teardown_build = create(:ci_build, :manual,
|
|
|
|
name: "#{deployment.environment.name}:teardown",
|
|
|
|
pipeline: deployment.deployable.pipeline)
|
|
|
|
|
|
|
|
deployment.update_column(:on_stop, teardown_build.name)
|
|
|
|
environment.update_attribute(:deployments, [deployment])
|
|
|
|
end
|
|
|
|
end
|
2016-06-14 11:51:12 +00:00
|
|
|
end
|
|
|
|
end
|