Make it possible to fabricate environment on branch
This commit is contained in:
parent
990765edf3
commit
ceb06983ec
|
@ -8,16 +8,21 @@ FactoryGirl.define do
|
||||||
trait :with_review_app do |environment|
|
trait :with_review_app do |environment|
|
||||||
project
|
project
|
||||||
|
|
||||||
|
transient do
|
||||||
|
ref 'master'
|
||||||
|
end
|
||||||
|
|
||||||
# At this point `review app` is an ephemeral concept related to
|
# At this point `review app` is an ephemeral concept related to
|
||||||
# deployments being deployed for given environment. There is no
|
# deployments being deployed for given environment. There is no
|
||||||
# first-class `review app` available so we need to create set of
|
# first-class `review app` available so we need to create set of
|
||||||
# interconnected objects to simulate a review app.
|
# interconnected objects to simulate a review app.
|
||||||
#
|
#
|
||||||
after(:create) do |environment|
|
after(:create) do |environment, evaluator|
|
||||||
deployment = create(:deployment,
|
deployment = create(:deployment,
|
||||||
environment: environment,
|
environment: environment,
|
||||||
project: environment.project,
|
project: environment.project,
|
||||||
sha: environment.project.commit.id)
|
ref: evaluator.ref,
|
||||||
|
sha: environment.project.commit(evaluator.ref).id)
|
||||||
|
|
||||||
teardown_build = create(:ci_build, :manual,
|
teardown_build = create(:ci_build, :manual,
|
||||||
name: "#{deployment.environment.name}:teardown",
|
name: "#{deployment.environment.name}:teardown",
|
||||||
|
|
|
@ -9,7 +9,8 @@ describe Ci::StopEnvironmentsService, services: true do
|
||||||
describe '#execute' do
|
describe '#execute' do
|
||||||
context 'when environment with review app exists' do
|
context 'when environment with review app exists' do
|
||||||
before do
|
before do
|
||||||
create(:environment, :with_review_app, project: project)
|
create(:environment, :with_review_app, project: project,
|
||||||
|
ref: 'feature')
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when user has permission to stop environment' do
|
context 'when user has permission to stop environment' do
|
||||||
|
@ -17,8 +18,16 @@ describe Ci::StopEnvironmentsService, services: true do
|
||||||
project.team << [user, :developer]
|
project.team << [user, :developer]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'stops environment' do
|
context 'when environment is associated with removed branch' do
|
||||||
expect_environment_stopped_on('master')
|
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
|
end
|
||||||
|
|
||||||
context 'when specified branch does not exist' do
|
context 'when specified branch does not exist' do
|
||||||
|
@ -40,7 +49,7 @@ describe Ci::StopEnvironmentsService, services: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not stop environment' do
|
it 'does not stop environment' do
|
||||||
expect_environment_not_stopped_on('master')
|
expect_environment_not_stopped_on('feature')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue