summaryrefslogtreecommitdiff
path: root/spec/features/projects/environments
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-03 09:07:33 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-03 09:07:33 +0000
commitc0d8f9f3f962df6bfcc70440432da55d67307189 (patch)
tree457666705fbbd4f517d201680113406163829fcc /spec/features/projects/environments
parent2cfa1fc75dd4bd6d1f70d5fee1a824410694f297 (diff)
downloadgitlab-ce-c0d8f9f3f962df6bfcc70440432da55d67307189.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/features/projects/environments')
-rw-r--r--spec/features/projects/environments/environment_spec.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/features/projects/environments/environment_spec.rb b/spec/features/projects/environments/environment_spec.rb
index 55c6aed19e0..bbd33225bb9 100644
--- a/spec/features/projects/environments/environment_spec.rb
+++ b/spec/features/projects/environments/environment_spec.rb
@@ -12,6 +12,10 @@ describe 'Environment' do
project.add_role(user, role)
end
+ def auto_stop_button_selector
+ %q{button[title="Prevent environment from auto-stopping"]}
+ end
+
describe 'environment details page' do
let!(:environment) { create(:environment, project: project) }
let!(:permissions) { }
@@ -27,6 +31,40 @@ describe 'Environment' do
expect(page).to have_content(environment.name)
end
+ context 'without auto-stop' do
+ it 'does not show auto-stop text' do
+ expect(page).not_to have_content('Auto stops')
+ end
+
+ it 'does not show auto-stop button' do
+ expect(page).not_to have_selector(auto_stop_button_selector)
+ end
+ end
+
+ context 'with auto-stop' do
+ let!(:environment) { create(:environment, :will_auto_stop, name: 'staging', project: project) }
+
+ before do
+ visit_environment(environment)
+ end
+
+ it 'shows auto stop info' do
+ expect(page).to have_content('Auto stops')
+ end
+
+ it 'shows auto stop button' do
+ expect(page).to have_selector(auto_stop_button_selector)
+ expect(page.find(auto_stop_button_selector).find(:xpath, '..')['action']).to have_content(cancel_auto_stop_project_environment_path(environment.project, environment))
+ end
+
+ it 'allows user to cancel auto stop', :js do
+ page.find(auto_stop_button_selector).click
+ wait_for_all_requests
+ expect(page).to have_content('Auto stop successfully canceled.')
+ expect(page).not_to have_selector(auto_stop_button_selector)
+ end
+ end
+
context 'without deployments' do
it 'does not show deployments' do
expect(page).to have_content('You don\'t have any deployments right now.')