summaryrefslogtreecommitdiff
path: root/spec/features/environments_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/features/environments_spec.rb')
-rw-r--r--spec/features/environments_spec.rb62
1 files changed, 59 insertions, 3 deletions
diff --git a/spec/features/environments_spec.rb b/spec/features/environments_spec.rb
index d0968b3e595..35f5706f920 100644
--- a/spec/features/environments_spec.rb
+++ b/spec/features/environments_spec.rb
@@ -18,11 +18,26 @@ feature 'Environments', feature: true do
before do
visit namespace_project_environments_path(project.namespace, project)
end
+
+ context 'shows two tabs' do
+ scenario 'does show Available tab with link' do
+ expect(page).to have_link('Available')
+ end
+
+ scenario 'does show Stopped tab with link' do
+ expect(page).to have_link('Stopped')
+ end
+ end
context 'without environments' do
scenario 'does show no environments' do
expect(page).to have_content('You don\'t have any environments right now.')
end
+
+ scenario 'does show 0 as counter for environments in both tabs' do
+ expect(page.find('.js-avaibale-environments-count').text).to eq('0')
+ expect(page.find('.js-stopped-environments-count').text).to eq('0')
+ end
end
context 'with environments' do
@@ -31,6 +46,14 @@ feature 'Environments', feature: true do
scenario 'does show environment name' do
expect(page).to have_link(environment.name)
end
+
+ scenario 'does show number of opened environments in Availabe tab' do
+ expect(page.find('.js-avaibale-environments-count').text).to eq('1')
+ end
+
+ scenario 'does show number of closed environments in Stopped tab' do
+ expect(page.find('.js-stopped-environments-count').text).to eq('0')
+ end
context 'without deployments' do
scenario 'does show no deployments' do
@@ -79,6 +102,16 @@ feature 'Environments', feature: true do
expect(page).to have_link(nil, href: environment.external_url)
end
end
+
+ scenario 'does show close button' do
+ # TODO: Add test to verify if close button is visible
+ # This needs to be true: if local_assigns.fetch(:allow_close, false) && deployment.closeable?
+ end
+
+ scenario 'does allow to close environment' do
+ # TODO: Add test to verify if close environment works
+ # This needs to be true: if local_assigns.fetch(:allow_close, false) && deployment.closeable?
+ end
end
end
end
@@ -150,6 +183,16 @@ feature 'Environments', feature: true do
expect(page).to have_link(nil, href: environment.external_url)
end
end
+
+ scenario 'does show close button' do
+ # TODO: Add test to verify if close button is visible
+ # This needs to be true: if local_assigns.fetch(:allow_close, false) && deployment.closeable?
+ end
+
+ scenario 'does allow to close environment' do
+ # TODO: Add test to verify if close environment works
+ # This needs to be true: if local_assigns.fetch(:allow_close, false) && deployment.closeable?
+ end
end
end
end
@@ -207,9 +250,22 @@ feature 'Environments', feature: true do
context 'when logged as master' do
given(:role) { :master }
- scenario 'does close environment' do
- click_link 'Close'
- expect(page).not_to have_link(environment.name)
+ scenario 'does not have a Close link' do
+ expect(page).not_to have_link('Close')
+ end
+
+ context 'when environment is opened and can be closed' do
+ let(:project) { create(:project) }
+ let(:environment) { create(:environment, project: project) }
+
+ let!(:deployment) do
+ create(:deployment, environment: environment, sha: project.commit('master').id)
+ end
+
+ scenario 'does have a Close link' do
+ # TODO: Add missing validation. In order to have Close link
+ # this must be true: last_deployment.try(:close_action)
+ end
end
end