Make it possible to fabricate environment on branch
This commit is contained in:
parent
990765edf3
commit
ceb06983ec
2 changed files with 20 additions and 6 deletions
|
@ -8,16 +8,21 @@ FactoryGirl.define do
|
|||
trait :with_review_app do |environment|
|
||||
project
|
||||
|
||||
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|
|
||||
after(:create) do |environment, evaluator|
|
||||
deployment = create(:deployment,
|
||||
environment: environment,
|
||||
project: environment.project,
|
||||
sha: environment.project.commit.id)
|
||||
ref: evaluator.ref,
|
||||
sha: environment.project.commit(evaluator.ref).id)
|
||||
|
||||
teardown_build = create(:ci_build, :manual,
|
||||
name: "#{deployment.environment.name}:teardown",
|
||||
|
|
|
@ -9,7 +9,8 @@ describe Ci::StopEnvironmentsService, services: true do
|
|||
describe '#execute' do
|
||||
context 'when environment with review app exists' do
|
||||
before do
|
||||
create(:environment, :with_review_app, project: project)
|
||||
create(:environment, :with_review_app, project: project,
|
||||
ref: 'feature')
|
||||
end
|
||||
|
||||
context 'when user has permission to stop environment' do
|
||||
|
@ -17,8 +18,16 @@ describe Ci::StopEnvironmentsService, services: true do
|
|||
project.team << [user, :developer]
|
||||
end
|
||||
|
||||
it 'stops environment' do
|
||||
expect_environment_stopped_on('master')
|
||||
context 'when environment is associated with removed branch' do
|
||||
it 'stops environment' do
|
||||
expect_environment_stopped_on('feature')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when environment is associated with different branch' do
|
||||
it 'does not stop environment' do
|
||||
expect_environment_not_stopped_on('master')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when specified branch does not exist' do
|
||||
|
@ -40,7 +49,7 @@ describe Ci::StopEnvironmentsService, services: true do
|
|||
end
|
||||
|
||||
it 'does not stop environment' do
|
||||
expect_environment_not_stopped_on('master')
|
||||
expect_environment_not_stopped_on('feature')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue