Commit 7aea16b6 authored by Kamil Trzcinski's avatar Kamil Trzcinski

Merge commit '7d12683d' into 22191-delete-dynamic-envs-mr [ci skip]

parents db9c03bf 7d12683d
...@@ -19,10 +19,25 @@ feature 'Environments', feature: true do ...@@ -19,10 +19,25 @@ feature 'Environments', feature: true do
visit namespace_project_environments_path(project.namespace, project) visit namespace_project_environments_path(project.namespace, project)
end 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 context 'without environments' do
scenario 'does show no environments' do scenario 'does show no environments' do
expect(page).to have_content('You don\'t have any environments right now.') expect(page).to have_content('You don\'t have any environments right now.')
end 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 end
context 'with environments' do context 'with environments' do
...@@ -32,6 +47,14 @@ feature 'Environments', feature: true do ...@@ -32,6 +47,14 @@ feature 'Environments', feature: true do
expect(page).to have_link(environment.name) expect(page).to have_link(environment.name)
end 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 context 'without deployments' do
scenario 'does show no deployments' do scenario 'does show no deployments' do
expect(page).to have_content('No deployments yet') expect(page).to have_content('No deployments yet')
...@@ -79,6 +102,16 @@ feature 'Environments', feature: true do ...@@ -79,6 +102,16 @@ feature 'Environments', feature: true do
expect(page).to have_link(nil, href: environment.external_url) expect(page).to have_link(nil, href: environment.external_url)
end end
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 end
end end
...@@ -150,6 +183,16 @@ feature 'Environments', feature: true do ...@@ -150,6 +183,16 @@ feature 'Environments', feature: true do
expect(page).to have_link(nil, href: environment.external_url) expect(page).to have_link(nil, href: environment.external_url)
end end
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 end
end end
...@@ -207,9 +250,22 @@ feature 'Environments', feature: true do ...@@ -207,9 +250,22 @@ feature 'Environments', feature: true do
context 'when logged as master' do context 'when logged as master' do
given(:role) { :master } given(:role) { :master }
scenario 'does close environment' do scenario 'does not have a Close link' do
click_link 'Close' expect(page).not_to have_link('Close')
expect(page).not_to have_link(environment.name) 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
end end
......
...@@ -102,6 +102,15 @@ feature 'Merge When Build Succeeds', feature: true, js: true do ...@@ -102,6 +102,15 @@ feature 'Merge When Build Succeeds', feature: true, js: true do
end end
end end
context 'Has Environment' do
let(:environment) { create(:environment, project: project) }
it 'does show link to close the environment' do
# TODO add test to verify if the button is visible when this condition
# is met: if environment.closeable?
end
end
def visit_merge_request(merge_request) def visit_merge_request(merge_request)
visit namespace_project_merge_request_path(merge_request.project.namespace, merge_request.project, merge_request) visit namespace_project_merge_request_path(merge_request.project.namespace, merge_request.project, merge_request)
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