diff options
author | Clement Ho <clemmakesapps@gmail.com> | 2017-06-22 08:57:11 +0300 |
---|---|---|
committer | Clement Ho <clemmakesapps@gmail.com> | 2017-06-22 08:57:11 +0300 |
commit | b3edcfeb51d7930ad0330e401f2ef5f27ee9671c (patch) | |
tree | a8d34dec7a3923f9ef807373980d62c2247ca394 /spec | |
parent | 31573d98f9e34a4fec6c41e0e8c8f3151e8837b5 (diff) | |
parent | 261e4fe8d8e6c01d0278a9e3770fe78d75336a07 (diff) |
Merge branch '9-3-stable-rc7' into '9-3-stable'
Prepare 9.3 RC7
See merge request !12348
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/projects/environments_controller_spec.rb | 6 | ||||
-rw-r--r-- | spec/features/dashboard/issues_spec.rb | 5 | ||||
-rw-r--r-- | spec/features/issues/bulk_assignment_labels_spec.rb | 19 | ||||
-rw-r--r-- | spec/features/projects/settings/repository_settings_spec.rb | 17 | ||||
-rw-r--r-- | spec/javascripts/filtered_search/filtered_search_manager_spec.js | 3 | ||||
-rw-r--r-- | spec/migrations/migrate_build_stage_reference_again_spec.rb (renamed from spec/migrations/migrate_build_stage_reference_spec.rb) | 4 | ||||
-rw-r--r-- | spec/models/ci/build_spec.rb | 48 | ||||
-rw-r--r-- | spec/requests/api/deploy_keys_spec.rb | 10 | ||||
-rw-r--r-- | spec/services/create_deployment_service_spec.rb | 55 | ||||
-rw-r--r-- | spec/support/capybara.rb | 5 |
10 files changed, 129 insertions, 43 deletions
diff --git a/spec/controllers/projects/environments_controller_spec.rb b/spec/controllers/projects/environments_controller_spec.rb index f6840578145..fcc79902a3c 100644 --- a/spec/controllers/projects/environments_controller_spec.rb +++ b/spec/controllers/projects/environments_controller_spec.rb @@ -58,9 +58,11 @@ describe Projects::EnvironmentsController do expect(json_response['stopped_count']).to eq 1 end - it 'sets the polling interval header' do + it 'does not set the polling interval header' do + # TODO, this is a temporary fix, see follow up issue: + # https://gitlab.com/gitlab-org/gitlab-ee/issues/2677 expect(response).to have_http_status(:ok) - expect(response.headers['Poll-Interval']).to eq("3000") + expect(response.headers['Poll-Interval']).to be_nil end end diff --git a/spec/features/dashboard/issues_spec.rb b/spec/features/dashboard/issues_spec.rb index 2cea6b1563e..3b987a0644d 100644 --- a/spec/features/dashboard/issues_spec.rb +++ b/spec/features/dashboard/issues_spec.rb @@ -59,6 +59,11 @@ RSpec.describe 'Dashboard Issues', feature: true do expect(page).to have_content(other_issue.title) end + it 'state filter tabs work' do + find('#state-closed').click + expect(page).to have_current_path(issues_dashboard_url(assignee_id: current_user.id, scope: 'all', state: 'closed'), url: true) + end + it_behaves_like "it has an RSS button with current_user's RSS token" it_behaves_like "an autodiscoverable RSS feed with current_user's RSS token" end diff --git a/spec/features/issues/bulk_assignment_labels_spec.rb b/spec/features/issues/bulk_assignment_labels_spec.rb index 95b4930cd32..67a098dd6c9 100644 --- a/spec/features/issues/bulk_assignment_labels_spec.rb +++ b/spec/features/issues/bulk_assignment_labels_spec.rb @@ -16,6 +16,21 @@ feature 'Issues > Labels bulk assignment', feature: true do login_as user end + context 'sidebar' do + before do + enable_bulk_update + end + + it 'is present when bulk edit is enabled' do + expect(page).to have_css('.issuable-sidebar') + end + + it 'is not present when bulk edit is disabled' do + disable_bulk_update + expect(page).not_to have_css('.issuable-sidebar') + end + end + context 'can bulk assign' do before do enable_bulk_update @@ -398,4 +413,8 @@ feature 'Issues > Labels bulk assignment', feature: true do visit namespace_project_issues_path(project.namespace, project) click_button 'Edit Issues' end + + def disable_bulk_update + click_button 'Cancel' + end end diff --git a/spec/features/projects/settings/repository_settings_spec.rb b/spec/features/projects/settings/repository_settings_spec.rb index 4cc38c5286e..a93f57eeec8 100644 --- a/spec/features/projects/settings/repository_settings_spec.rb +++ b/spec/features/projects/settings/repository_settings_spec.rb @@ -65,6 +65,23 @@ feature 'Repository settings', feature: true do expect(page).to have_content('Write access allowed') end + scenario 'edit a deploy key from projects user has access to' do + project2 = create(:project_empty_repo) + project2.team << [user, role] + project2.deploy_keys << private_deploy_key + + visit namespace_project_settings_repository_path(project.namespace, project) + + find('li', text: private_deploy_key.title).click_link('Edit') + + fill_in 'deploy_key_title', with: 'updated_deploy_key' + check 'deploy_key_can_push' + click_button 'Save changes' + + expect(page).to have_content('updated_deploy_key') + expect(page).to have_content('Write access allowed') + end + scenario 'remove an existing deploy key' do project.deploy_keys << private_deploy_key visit namespace_project_settings_repository_path(project.namespace, project) diff --git a/spec/javascripts/filtered_search/filtered_search_manager_spec.js b/spec/javascripts/filtered_search/filtered_search_manager_spec.js index 6d00d71f145..b9286d2827a 100644 --- a/spec/javascripts/filtered_search/filtered_search_manager_spec.js +++ b/spec/javascripts/filtered_search/filtered_search_manager_spec.js @@ -104,6 +104,7 @@ describe('Filtered Search Manager', () => { it('should blur button', () => { const e = { + preventDefault: () => {}, currentTarget: { blur: () => {}, }, @@ -116,6 +117,7 @@ describe('Filtered Search Manager', () => { it('should not call search if there is no state', () => { const e = { + preventDefault: () => {}, currentTarget: { blur: () => {}, }, @@ -127,6 +129,7 @@ describe('Filtered Search Manager', () => { it('should call search when there is state', () => { const e = { + preventDefault: () => {}, currentTarget: { blur: () => {}, dataset: { diff --git a/spec/migrations/migrate_build_stage_reference_spec.rb b/spec/migrations/migrate_build_stage_reference_again_spec.rb index 80b321860c2..6be480ce58e 100644 --- a/spec/migrations/migrate_build_stage_reference_spec.rb +++ b/spec/migrations/migrate_build_stage_reference_again_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' -require Rails.root.join('db', 'post_migrate', '20170526185921_migrate_build_stage_reference.rb') +require Rails.root.join('db', 'post_migrate', '20170526190000_migrate_build_stage_reference_again.rb') -describe MigrateBuildStageReference, :migration do +describe MigrateBuildStageReferenceAgain, :migration do ## # Create test data - pipeline and CI/CD jobs. # diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index b06e77c34f6..d983a50e3df 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -439,42 +439,6 @@ describe Ci::Build, :models do end end - describe '#environment_url' do - subject { job.environment_url } - - context 'when yaml environment uses $CI_COMMIT_REF_NAME' do - let(:job) do - create(:ci_build, - ref: 'master', - options: { environment: { url: 'http://review/$CI_COMMIT_REF_NAME' } }) - end - - it { is_expected.to eq('http://review/master') } - end - - context 'when yaml environment uses yaml_variables containing symbol keys' do - let(:job) do - create(:ci_build, - yaml_variables: [{ key: :APP_HOST, value: 'host' }], - options: { environment: { url: 'http://review/$APP_HOST' } }) - end - - it { is_expected.to eq('http://review/host') } - end - - context 'when yaml environment does not have url' do - let(:job) { create(:ci_build, environment: 'staging') } - - let!(:environment) do - create(:environment, project: job.project, name: job.environment) - end - - it 'returns the external_url from persisted environment' do - is_expected.to eq(environment.external_url) - end - end - end - describe '#starts_environment?' do subject { build.starts_environment? } @@ -1276,10 +1240,20 @@ describe Ci::Build, :models do context 'when the URL was set from the job' do before do - build.update(options: { environment: { url: 'http://host/$CI_JOB_NAME' } }) + build.update(options: { environment: { url: url } }) end it_behaves_like 'containing environment variables' + + context 'when variables are used in the URL, it does not expand' do + let(:url) { 'http://$CI_PROJECT_NAME-$CI_ENVIRONMENT_SLUG' } + + it_behaves_like 'containing environment variables' + + it 'puts $CI_ENVIRONMENT_URL in the last so all other variables are available to be used when runners are trying to expand it' do + expect(subject.last).to eq(environment_variables.last) + end + end end context 'when the URL was not set from the job, but environment' do diff --git a/spec/requests/api/deploy_keys_spec.rb b/spec/requests/api/deploy_keys_spec.rb index 4d9cd5f3a27..42332d27c06 100644 --- a/spec/requests/api/deploy_keys_spec.rb +++ b/spec/requests/api/deploy_keys_spec.rb @@ -158,6 +158,16 @@ describe API::DeployKeys do expect(json_response['title']).to eq('new title') expect(json_response['can_push']).to eq(true) end + + it 'updates a private ssh key from projects user has access with correct attributes' do + create(:deploy_keys_project, project: project2, deploy_key: private_deploy_key) + + put api("/projects/#{project.id}/deploy_keys/#{private_deploy_key.id}", admin), { title: 'new title', can_push: true } + + expect(json_response['id']).to eq(private_deploy_key.id) + expect(json_response['title']).to eq('new title') + expect(json_response['can_push']).to eq(true) + end end describe 'DELETE /projects/:id/deploy_keys/:key_id' do diff --git a/spec/services/create_deployment_service_spec.rb b/spec/services/create_deployment_service_spec.rb index 5398b5c3f7e..a898d6327ac 100644 --- a/spec/services/create_deployment_service_spec.rb +++ b/spec/services/create_deployment_service_spec.rb @@ -122,6 +122,61 @@ describe CreateDeploymentService, services: true do end end + describe '#expanded_environment_url' do + subject { service.send(:expanded_environment_url) } + + context 'when yaml environment uses $CI_COMMIT_REF_NAME' do + let(:job) do + create(:ci_build, + ref: 'master', + options: { environment: { url: 'http://review/$CI_COMMIT_REF_NAME' } }) + end + + it { is_expected.to eq('http://review/master') } + end + + context 'when yaml environment uses $CI_ENVIRONMENT_SLUG' do + let(:job) do + create(:ci_build, + ref: 'master', + environment: 'production', + options: { environment: { url: 'http://review/$CI_ENVIRONMENT_SLUG' } }) + end + + let!(:environment) do + create(:environment, + project: job.project, + name: 'production', + slug: 'prod-slug', + external_url: 'http://review/old') + end + + it { is_expected.to eq('http://review/prod-slug') } + end + + context 'when yaml environment uses yaml_variables containing symbol keys' do + let(:job) do + create(:ci_build, + yaml_variables: [{ key: :APP_HOST, value: 'host' }], + options: { environment: { url: 'http://review/$APP_HOST' } }) + end + + it { is_expected.to eq('http://review/host') } + end + + context 'when yaml environment does not have url' do + let(:job) { create(:ci_build, environment: 'staging') } + + let!(:environment) do + create(:environment, project: job.project, name: job.environment) + end + + it 'returns the external_url from persisted environment' do + is_expected.to be_nil + end + end + end + describe 'processing of builds' do shared_examples 'does not create deployment' do it 'does not create a new deployment' do diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb index 4aa81a03558..3e5d6cf1364 100644 --- a/spec/support/capybara.rb +++ b/spec/support/capybara.rb @@ -36,12 +36,13 @@ RSpec.configure do |config| $capybara_server_already_started = true end - config.after(:each, :js) do + config.after(:each, :js) do |example| # capybara/rspec already calls Capybara.reset_sessions! in an `after` hook, # but `block_and_wait_for_requests_complete` is called before it so by # calling it explicitely here, we prevent any new requests from being fired # See https://github.com/teamcapybara/capybara/blob/ffb41cfad620de1961bb49b1562a9fa9b28c0903/lib/capybara/rspec.rb#L20-L25 - Capybara.reset_sessions! + # We don't reset the session when the example failed, because we need capybara-screenshot to have access to it. + Capybara.reset_sessions! unless example.exception block_and_wait_for_requests_complete end end |