Commit 32a400aa authored by Kamil Trzcinski's avatar Kamil Trzcinski

Make environments_spec more feature-spec

parent 18fd2ccb
require 'spec_helper' require 'spec_helper'
describe 'Environments' do feature 'Environments', feature: true do
include GitlabRoutingHelper given(:project) { create(:empty_project) }
given(:user) { create(:user) }
given(:role) { :developer }
let(:project) { create(:empty_project) } background do
let(:user) { create(:user) }
let(:role) { :developer }
before do
login_as(user) login_as(user)
project.team << [user, role] project.team << [user, role]
end end
describe 'GET /:project/environments' do describe 'when showing environments' do
subject { visit namespace_project_environments_path(project.namespace, project) } given!(:environment) { }
given!(:deployment) { }
context 'without environments' do before do
it 'does show no environments' do visit namespace_project_environments_path(project.namespace, project)
subject end
context 'without environments' do
scenario 'does show no environments' do
expect(page).to have_content('No environments to show') expect(page).to have_content('No environments to show')
end end
end end
context 'with environments' do context 'with environments' do
let!(:environment) { create(:environment, project: project) } given(:environment) { create(:environment, project: project) }
it 'does show environment name' do
subject
scenario 'does show environment name' do
expect(page).to have_link(environment.name) expect(page).to have_link(environment.name)
end end
context 'without deployments' do context 'without deployments' do
it 'does show no deployments' do scenario 'does show no deployments' do
subject
expect(page).to have_content('No deployments yet') expect(page).to have_content('No deployments yet')
end end
end end
context 'with deployments' do context 'with deployments' do
let!(:deployment) { create(:deployment, environment: environment) } given(:deployment) { create(:deployment, environment: environment) }
it 'does show deployment SHA' do
subject
scenario 'does show deployment SHA' do
expect(page).to have_link(deployment.short_sha) expect(page).to have_link(deployment.short_sha)
end end
end end
end end
it 'does have a New environment button' do scenario 'does have a New environment button' do
subject
expect(page).to have_link('New environment') expect(page).to have_link('New environment')
end end
end end
describe 'GET /:project/environments/:id' do describe 'when showing the environment' do
let(:environment) { create(:environment, project: project) } given(:environment) { create(:environment, project: project) }
given!(:deployment) { }
subject { visit namespace_project_environment_path(project.namespace, project, environment) } before do
visit namespace_project_environment_path(project.namespace, project, environment)
end
context 'without deployments' do context 'without deployments' do
it 'does show no deployments' do scenario 'does show no deployments' do
subject
expect(page).to have_content('No deployments for') expect(page).to have_content('No deployments for')
end end
end end
context 'with deployments' do context 'with deployments' do
let!(:deployment) { create(:deployment, environment: environment) } given(:deployment) { create(:deployment, environment: environment) }
before { subject } scenario 'does show deployment SHA' do
it 'does show deployment SHA' do
expect(page).to have_link(deployment.short_sha) expect(page).to have_link(deployment.short_sha)
end end
it 'does not show a retry button for deployment without build' do scenario 'does not show a retry button for deployment without build' do
expect(page).not_to have_link('Retry') expect(page).not_to have_link('Retry')
end end
context 'with build' do context 'with build' do
let(:build) { create(:ci_build, project: project) } given(:build) { create(:ci_build, project: project) }
let(:deployment) { create(:deployment, environment: environment, deployable: build) } given(:deployment) { create(:deployment, environment: environment, deployable: build) }
it 'does show build name' do scenario 'does show build name' do
expect(page).to have_link("#{build.name} (##{build.id})") expect(page).to have_link("#{build.name} (##{build.id})")
end end
it 'does show retry button' do scenario 'does show retry button' do
expect(page).to have_link('Retry') expect(page).to have_link('Retry')
end end
end end
end end
end end
describe 'POST /:project/environments' do describe 'when creating a new environment' do
before { visit namespace_project_environments_path(project.namespace, project) } before do
visit namespace_project_environments_path(project.namespace, project)
end
context 'when logged as developer' do context 'when logged as developer' do
before { click_link 'New environment' } before do
click_link 'New environment'
end
context 'for valid name' do context 'for valid name' do
before do before do
...@@ -111,7 +107,7 @@ describe 'Environments' do ...@@ -111,7 +107,7 @@ describe 'Environments' do
click_on 'Create environment' click_on 'Create environment'
end end
it 'does create a new pipeline' do scenario 'does create a new pipeline' do
expect(page).to have_content('production') expect(page).to have_content('production')
end end
end end
...@@ -122,38 +118,41 @@ describe 'Environments' do ...@@ -122,38 +118,41 @@ describe 'Environments' do
click_on 'Create environment' click_on 'Create environment'
end end
it { expect(page).to have_content('Name can contain only letters') } scenario 'does show errors' do
expect(page).to have_content('Name can contain only letters')
end
end end
end end
context 'when logged as reporter' do context 'when logged as reporter' do
let(:role) { :reporter } given(:role) { :reporter }
it 'does not have a New environment link' do scenario 'does not have a New environment link' do
expect(page).not_to have_link('New environment') expect(page).not_to have_link('New environment')
end end
end end
end end
describe 'DELETE /:project/environments/:id' do describe 'when deleting existing environment' do
let(:environment) { create(:environment, project: project) } given(:environment) { create(:environment, project: project) }
before { visit namespace_project_environment_path(project.namespace, project, environment) } before do
visit namespace_project_environment_path(project.namespace, project, environment)
end
context 'when logged as master' do context 'when logged as master' do
let(:role) { :master } given(:role) { :master }
before { click_link 'Destroy' }
it 'does not have environment' do scenario 'does delete environment' do
click_link 'Destroy'
expect(page).not_to have_link(environment.name) expect(page).not_to have_link(environment.name)
end end
end end
context 'when logged as developer' do context 'when logged as developer' do
let(:role) { :developer } given(:role) { :developer }
it 'does not have a Destroy link' do scenario 'does not have a Destroy link' do
expect(page).not_to have_link('Destroy') expect(page).not_to have_link('Destroy')
end 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