Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-11-09 11:42:09 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-11-09 11:42:09 +0300
commitf7ef7bea11012bef6d373ce3b3c43fac08b047fd (patch)
treee99ead5b9b7fd34477d29ef0d4792bd8e4e27689 /spec/factories
parent04a8372cdfff501fe67c17612a0b5e098f7d56c9 (diff)
Add environment factory review app trait
Diffstat (limited to 'spec/factories')
-rw-r--r--spec/factories/deployments.rb3
-rw-r--r--spec/factories/environments.rb23
2 files changed, 25 insertions, 1 deletions
diff --git a/spec/factories/deployments.rb b/spec/factories/deployments.rb
index 6f24bf58d14..29ad1af9fd9 100644
--- a/spec/factories/deployments.rb
+++ b/spec/factories/deployments.rb
@@ -3,8 +3,9 @@ FactoryGirl.define do
sha '97de212e80737a608d939f648d959671fb0a0142'
ref 'master'
tag false
+ user
project nil
-
+ deployable factory: :ci_build
environment factory: :environment
after(:build) do |deployment, evaluator|
diff --git a/spec/factories/environments.rb b/spec/factories/environments.rb
index 846cccfc7fa..bb6558a403f 100644
--- a/spec/factories/environments.rb
+++ b/spec/factories/environments.rb
@@ -4,5 +4,28 @@ FactoryGirl.define do
project factory: :empty_project
sequence(:external_url) { |n| "https://env#{n}.example.gitlab.com" }
+
+ 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
end
end