Skip to content
Snippets Groups Projects
Commit 45bd5391 authored by Grzegorz Bizon's avatar Grzegorz Bizon
Browse files

Extend tests for service that stops environment

parent ae8a461d
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -7,7 +7,7 @@
let(:service) { described_class.new(project, user) }
 
describe '#execute' do
context 'when environment exists' do
context 'when environment with review app exists' do
before do
create(:environment, :with_review_app, project: project)
end
Loading
Loading
@@ -17,6 +17,54 @@
 
service.execute('master')
end
context 'when specified branch does not exist' do
it 'does not stop environment' do
expect_any_instance_of(Environment).not_to receive(:stop!)
service.execute('non/existent/branch')
end
end
context 'when no branch not specified' do
it 'does not stop environment' do
expect_any_instance_of(Environment).not_to receive(:stop!)
service.execute(nil)
end
end
context 'when environment is not stoppable' do
before do
allow_any_instance_of(Environment)
.to receive(:stoppable?).and_return(false)
end
it 'does not stop environment' do
expect_any_instance_of(Environment).not_to receive(:stop!)
service.execute('master')
end
end
end
context 'when there is no environment associated with review app' do
before do
create(:environment, project: project)
end
it 'does not stop environment' do
expect_any_instance_of(Environment).not_to receive(:stop!)
service.execute('master')
end
end
context 'when environment does not exist' do
it 'does not raise error' do
expect { service.execute('master') }
.not_to raise_error
end
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment