diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-06-15 13:24:47 +0300 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-06-15 13:24:47 +0300 |
commit | 32a400aa14a0f2b2245251cb831fdc688917b4c1 (patch) | |
tree | dda265046624a68bc883d28e572a4655ea3098b1 /spec | |
parent | 18fd2ccb8b9b60e2acd6782a4160f85d3ee6c95f (diff) |
Make environments_spec more feature-spec
Diffstat (limited to 'spec')
-rw-r--r-- | spec/features/environments_spec.rb | 113 |
1 files changed, 56 insertions, 57 deletions
diff --git a/spec/features/environments_spec.rb b/spec/features/environments_spec.rb index 8002b793986..40fea5211e9 100644 --- a/spec/features/environments_spec.rb +++ b/spec/features/environments_spec.rb @@ -1,109 +1,105 @@ require 'spec_helper' -describe 'Environments' do - include GitlabRoutingHelper +feature 'Environments', feature: true do + given(:project) { create(:empty_project) } + given(:user) { create(:user) } + given(:role) { :developer } - let(:project) { create(:empty_project) } - let(:user) { create(:user) } - let(:role) { :developer } - - before do + background do login_as(user) project.team << [user, role] end - describe 'GET /:project/environments' do - subject { visit namespace_project_environments_path(project.namespace, project) } + describe 'when showing environments' do + given!(:environment) { } + given!(:deployment) { } - context 'without environments' do - it 'does show no environments' do - subject + before do + visit namespace_project_environments_path(project.namespace, project) + end + context 'without environments' do + scenario 'does show no environments' do expect(page).to have_content('No environments to show') end end context 'with environments' do - let!(:environment) { create(:environment, project: project) } - - it 'does show environment name' do - subject + given(:environment) { create(:environment, project: project) } + scenario 'does show environment name' do expect(page).to have_link(environment.name) end context 'without deployments' do - it 'does show no deployments' do - subject - + scenario 'does show no deployments' do expect(page).to have_content('No deployments yet') end end context 'with deployments' do - let!(:deployment) { create(:deployment, environment: environment) } - - it 'does show deployment SHA' do - subject + given(:deployment) { create(:deployment, environment: environment) } + scenario 'does show deployment SHA' do expect(page).to have_link(deployment.short_sha) end end end - it 'does have a New environment button' do - subject - + scenario 'does have a New environment button' do expect(page).to have_link('New environment') end end - describe 'GET /:project/environments/:id' do - let(:environment) { create(:environment, project: project) } + describe 'when showing the environment' do + 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 - it 'does show no deployments' do - subject - + scenario 'does show no deployments' do expect(page).to have_content('No deployments for') end end context 'with deployments' do - let!(:deployment) { create(:deployment, environment: environment) } + given(:deployment) { create(:deployment, environment: environment) } - before { subject } - - it 'does show deployment SHA' do + scenario 'does show deployment SHA' do expect(page).to have_link(deployment.short_sha) 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') end context 'with build' do - let(:build) { create(:ci_build, project: project) } - let(:deployment) { create(:deployment, environment: environment, deployable: build) } + given(:build) { create(:ci_build, project: project) } + 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})") end - it 'does show retry button' do + scenario 'does show retry button' do expect(page).to have_link('Retry') end end end end - describe 'POST /:project/environments' do - before { visit namespace_project_environments_path(project.namespace, project) } + describe 'when creating a new environment' do + before do + visit namespace_project_environments_path(project.namespace, project) + end context 'when logged as developer' do - before { click_link 'New environment' } + before do + click_link 'New environment' + end context 'for valid name' do before do @@ -111,7 +107,7 @@ describe 'Environments' do click_on 'Create environment' end - it 'does create a new pipeline' do + scenario 'does create a new pipeline' do expect(page).to have_content('production') end end @@ -122,38 +118,41 @@ describe 'Environments' do click_on 'Create environment' 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 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') end end end - describe 'DELETE /:project/environments/:id' do - let(:environment) { create(:environment, project: project) } + describe 'when deleting existing environment' do + 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 - let(:role) { :master } - - before { click_link 'Destroy' } + given(:role) { :master } - it 'does not have environment' do + scenario 'does delete environment' do + click_link 'Destroy' expect(page).not_to have_link(environment.name) end end 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') end end |