diff options
author | Winnie Hellmann <winnie@gitlab.com> | 2018-07-05 09:32:05 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-07-05 09:32:05 +0300 |
commit | 3db2f327594e134729a0ca2f48a748bb28ab7d6c (patch) | |
tree | 661033b988897aaf506c0deaf457c2002e17d51b /spec/features/projects/environments | |
parent | baab4cddb091c0aa9649fecc340b8b343747ba83 (diff) |
Enable Capybara/FeatureMethods cop
Diffstat (limited to 'spec/features/projects/environments')
3 files changed, 71 insertions, 71 deletions
diff --git a/spec/features/projects/environments/environment_metrics_spec.rb b/spec/features/projects/environments/environment_metrics_spec.rb index 82a722c5960..edbab14f7c1 100644 --- a/spec/features/projects/environments/environment_metrics_spec.rb +++ b/spec/features/projects/environments/environment_metrics_spec.rb @@ -1,16 +1,16 @@ require 'spec_helper' -feature 'Environment > Metrics' do +describe 'Environment > Metrics' do include PrometheusHelpers - given(:user) { create(:user) } - given(:project) { create(:prometheus_project) } - given(:pipeline) { create(:ci_pipeline, project: project) } - given(:build) { create(:ci_build, pipeline: pipeline) } - given(:environment) { create(:environment, project: project) } - given(:current_time) { Time.now.utc } + let(:user) { create(:user) } + let(:project) { create(:prometheus_project) } + let(:pipeline) { create(:ci_pipeline, project: project) } + let(:build) { create(:ci_build, pipeline: pipeline) } + let(:environment) { create(:environment, project: project) } + let(:current_time) { Time.now.utc } - background do + before do project.add_developer(user) create(:deployment, environment: environment, deployable: build) stub_all_prometheus_requests(environment.slug) @@ -24,7 +24,7 @@ feature 'Environment > Metrics' do end context 'with deployments and related deployable present' do - scenario 'shows metrics' do + it 'shows metrics' do click_link('See metrics') expect(page).to have_css('div#prometheus-graphs') diff --git a/spec/features/projects/environments/environment_spec.rb b/spec/features/projects/environments/environment_spec.rb index b233af83eec..0c34309c1f4 100644 --- a/spec/features/projects/environments/environment_spec.rb +++ b/spec/features/projects/environments/environment_spec.rb @@ -1,42 +1,42 @@ require 'spec_helper' -feature 'Environment' do - given(:project) { create(:project) } - given(:user) { create(:user) } - given(:role) { :developer } +describe 'Environment' do + let(:project) { create(:project) } + let(:user) { create(:user) } + let(:role) { :developer } - background do + before do sign_in(user) project.add_role(user, role) end - feature 'environment details page' do - given!(:environment) { create(:environment, project: project) } - given!(:permissions) { } - given!(:deployment) { } - given!(:action) { } + describe 'environment details page' do + let!(:environment) { create(:environment, project: project) } + let!(:permissions) { } + let!(:deployment) { } + let!(:action) { } before do visit_environment(environment) end - scenario 'shows environment name' do + it 'shows environment name' do expect(page).to have_content(environment.name) end context 'without deployments' do - scenario 'does show no deployments' do + it 'does show no deployments' do expect(page).to have_content('You don\'t have any deployments right now.') end end context 'with deployments' do context 'when there is no related deployable' do - given(:deployment) do + let(:deployment) do create(:deployment, environment: environment, deployable: nil) end - scenario 'does show deployment SHA' do + it 'does show deployment SHA' do expect(page).to have_link(deployment.short_sha) expect(page).not_to have_link('Re-deploy') expect(page).not_to have_terminal_button @@ -44,27 +44,27 @@ feature 'Environment' do end context 'with related deployable present' do - given(:pipeline) { create(:ci_pipeline, project: project) } - given(:build) { create(:ci_build, pipeline: pipeline) } + let(:pipeline) { create(:ci_pipeline, project: project) } + let(:build) { create(:ci_build, pipeline: pipeline) } - given(:deployment) do + let(:deployment) do create(:deployment, environment: environment, deployable: build) end - scenario 'does show build name' do + it 'does show build name' do expect(page).to have_link("#{build.name} (##{build.id})") expect(page).to have_link('Re-deploy') expect(page).not_to have_terminal_button end context 'with manual action' do - given(:action) do + let(:action) do create(:ci_build, :manual, pipeline: pipeline, name: 'deploy to production') end context 'when user has ability to trigger deployment' do - given(:permissions) do + let(:permissions) do create(:protected_branch, :developers_can_merge, name: action.ref, project: project) end @@ -91,11 +91,11 @@ feature 'Environment' do end context 'with external_url' do - given(:environment) { create(:environment, project: project, external_url: 'https://git.gitlab.com') } - given(:build) { create(:ci_build, pipeline: pipeline) } - given(:deployment) { create(:deployment, environment: environment, deployable: build) } + let(:environment) { create(:environment, project: project, external_url: 'https://git.gitlab.com') } + let(:build) { create(:ci_build, pipeline: pipeline) } + let(:deployment) { create(:deployment, environment: environment, deployable: build) } - scenario 'does show an external link button' do + it 'does show an external link button' do expect(page).to have_link(nil, href: environment.external_url) end end @@ -105,7 +105,7 @@ feature 'Environment' do context 'for project master' do let(:role) { :master } - scenario 'it shows the terminal button' do + it 'it shows the terminal button' do expect(page).to have_terminal_button end @@ -126,7 +126,7 @@ feature 'Environment' do context 'for developer' do let(:role) { :developer } - scenario 'does not show terminal button' do + it 'does not show terminal button' do expect(page).not_to have_terminal_button end end @@ -148,19 +148,19 @@ feature 'Environment' do context 'when environment is available' do context 'with stop action' do - given(:action) do + let(:action) do create(:ci_build, :manual, pipeline: pipeline, name: 'close_app') end - given(:deployment) do + let(:deployment) do create(:deployment, environment: environment, deployable: build, on_stop: 'close_app') end context 'when user has ability to stop environment' do - given(:permissions) do + let(:permissions) do create(:protected_branch, :developers_can_merge, name: action.ref, project: project) end @@ -181,7 +181,7 @@ feature 'Environment' do context 'for reporter' do let(:role) { :reporter } - scenario 'does not show stop button' do + it 'does not show stop button' do expect(page).not_to have_link('Stop') end end @@ -189,9 +189,9 @@ feature 'Environment' do end context 'when environment is stopped' do - given(:environment) { create(:environment, project: project, state: :stopped) } + let(:environment) { create(:environment, project: project, state: :stopped) } - scenario 'does not show stop button' do + it 'does not show stop button' do expect(page).not_to have_link('Stop') end end @@ -200,7 +200,7 @@ feature 'Environment' do end end - feature 'environment folders', :js do + describe 'environment folders', :js do context 'when folder name contains special charaters' do before do create(:environment, project: project, @@ -219,21 +219,21 @@ feature 'Environment' do end end - feature 'auto-close environment when branch is deleted' do - given(:project) { create(:project, :repository) } + describe 'auto-close environment when branch is deleted' do + let(:project) { create(:project, :repository) } - given!(:environment) do + let!(:environment) do create(:environment, :with_review_app, project: project, ref: 'feature') end - scenario 'user visits environment page' do + it 'user visits environment page' do visit_environment(environment) expect(page).to have_link('Stop') end - scenario 'user deletes the branch with running environment' do + it 'user deletes the branch with running environment' do visit project_branches_filtered_path(project, state: 'all', search: 'feature') remove_branch_with_hooks(project, user, 'feature') do diff --git a/spec/features/projects/environments/environments_spec.rb b/spec/features/projects/environments/environments_spec.rb index f9defa22d35..9900c13095e 100644 --- a/spec/features/projects/environments/environments_spec.rb +++ b/spec/features/projects/environments/environments_spec.rb @@ -1,11 +1,11 @@ require 'spec_helper' -feature 'Environments page', :js do - given(:project) { create(:project) } - given(:user) { create(:user) } - given(:role) { :developer } +describe 'Environments page', :js do + let(:project) { create(:project) } + let(:user) { create(:user) } + let(:role) { :developer } - background do + before do project.add_role(user, role) sign_in(user) end @@ -99,7 +99,7 @@ feature 'Environments page', :js do end describe 'environments table' do - given!(:environment) do + let!(:environment) do create(:environment, project: project, state: :available) end @@ -125,9 +125,9 @@ feature 'Environments page', :js do end context 'when there are deployments' do - given(:project) { create(:project, :repository) } + let(:project) { create(:project, :repository) } - given!(:deployment) do + let!(:deployment) do create(:deployment, environment: environment, sha: project.commit.id) end @@ -140,14 +140,14 @@ feature 'Environments page', :js do end context 'when builds and manual actions are present' do - given!(:pipeline) { create(:ci_pipeline, project: project) } - given!(:build) { create(:ci_build, pipeline: pipeline) } + let!(:pipeline) { create(:ci_pipeline, project: project) } + let!(:build) { create(:ci_build, pipeline: pipeline) } - given!(:action) do + let!(:action) do create(:ci_build, :manual, pipeline: pipeline, name: 'deploy to production') end - given!(:deployment) do + let!(:deployment) do create(:deployment, environment: environment, deployable: build, sha: project.commit.id) @@ -190,9 +190,9 @@ feature 'Environments page', :js do end context 'with external_url' do - given(:environment) { create(:environment, project: project, external_url: 'https://git.gitlab.com') } - given(:build) { create(:ci_build, pipeline: pipeline) } - given(:deployment) { create(:deployment, environment: environment, deployable: build) } + let(:environment) { create(:environment, project: project, external_url: 'https://git.gitlab.com') } + let(:build) { create(:ci_build, pipeline: pipeline) } + let(:deployment) { create(:deployment, environment: environment, deployable: build) } it 'shows an external link button' do expect(page).to have_link(nil, href: environment.external_url) @@ -200,11 +200,11 @@ feature 'Environments page', :js do end context 'with stop action' do - given(:action) do + let(:action) do create(:ci_build, :manual, pipeline: pipeline, name: 'close_app') end - given(:deployment) do + let(:deployment) do create(:deployment, environment: environment, deployable: build, on_stop: 'close_app') @@ -271,9 +271,9 @@ feature 'Environments page', :js do end context 'user is a developer' do - given(:role) { :developer } + let(:role) { :developer } - scenario 'developer creates a new environment with a valid name' do + it 'developer creates a new environment with a valid name' do within(".top-area") { click_link 'New environment' } fill_in('Name', with: 'production') click_on 'Save' @@ -281,7 +281,7 @@ feature 'Environments page', :js do expect(page).to have_content('production') end - scenario 'developer creates a new environmetn with invalid name' do + it 'developer creates a new environmetn with invalid name' do within(".top-area") { click_link 'New environment' } fill_in('Name', with: 'name,with,commas') click_on 'Save' @@ -291,9 +291,9 @@ feature 'Environments page', :js do end context 'user is a reporter' do - given(:role) { :reporter } + let(:role) { :reporter } - scenario 'reporters tries to create a new environment' do + it 'reporters tries to create a new environment' do expect(page).not_to have_link('New environment') end end @@ -309,7 +309,7 @@ feature 'Environments page', :js do state: :available) end - scenario 'users unfurls an environment folder' do + it 'users unfurls an environment folder' do visit_environments(project) expect(page).not_to have_content 'review-1' @@ -335,7 +335,7 @@ feature 'Environments page', :js do state: :available) end - scenario 'user opens folder view' do + it 'user opens folder view' do visit folder_project_environments_path(project, 'staging.review') wait_for_requests |