Commit a88b2d3b authored by Grzegorz Bizon's avatar Grzegorz Bizon

Add feature tests for environments auto-close

parent ceb06983
...@@ -92,6 +92,7 @@ class Environment < ActiveRecord::Base ...@@ -92,6 +92,7 @@ class Environment < ActiveRecord::Base
def stop!(current_user) def stop!(current_user)
return unless stoppable? return unless stoppable?
stop
stop_action.play(current_user) stop_action.play(current_user)
end end
end end
...@@ -6,8 +6,8 @@ feature 'Environments', feature: true do ...@@ -6,8 +6,8 @@ feature 'Environments', feature: true do
given(:role) { :developer } given(:role) { :developer }
background do background do
login_as(user)
project.team << [user, role] project.team << [user, role]
login_as(user)
end end
describe 'when showing environments' do describe 'when showing environments' do
...@@ -16,7 +16,7 @@ feature 'Environments', feature: true do ...@@ -16,7 +16,7 @@ feature 'Environments', feature: true do
given!(:manual) { } given!(:manual) { }
before do before do
visit namespace_project_environments_path(project.namespace, project) visit_environments(project)
end end
context 'shows two tabs' do context 'shows two tabs' do
...@@ -142,7 +142,7 @@ feature 'Environments', feature: true do ...@@ -142,7 +142,7 @@ feature 'Environments', feature: true do
given!(:manual) { } given!(:manual) { }
before do before do
visit namespace_project_environment_path(project.namespace, project, environment) visit_environment(environment)
end end
context 'without deployments' do context 'without deployments' do
...@@ -234,7 +234,7 @@ feature 'Environments', feature: true do ...@@ -234,7 +234,7 @@ feature 'Environments', feature: true do
describe 'when creating a new environment' do describe 'when creating a new environment' do
before do before do
visit namespace_project_environments_path(project.namespace, project) visit_environments(project)
end end
context 'when logged as developer' do context 'when logged as developer' do
...@@ -273,4 +273,38 @@ feature 'Environments', feature: true do ...@@ -273,4 +273,38 @@ feature 'Environments', feature: true do
end end
end end
end end
feature 'auto-close environment when branch deleted' do
given(:project) { create(:project) }
given!(:environment) do
create(:environment, :with_review_app, project: project,
ref: 'feature')
end
scenario 'user visits environment page' do
visit_environment(environment)
expect(page).to have_link('Stop')
end
scenario 'user deletes the branch with running environment' do
visit namespace_project_branches_path(project.namespace, project)
page.within('.js-branch-feature') { find('a.btn-remove').click }
visit_environment(environment)
expect(page).to have_no_link('Stop')
end
end
def visit_environments(project)
visit namespace_project_environments_path(project.namespace, project)
end
def visit_environment(environment)
visit namespace_project_environment_path(environment.project.namespace,
environment.project,
environment)
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment