diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-15 21:06:25 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-15 21:06:25 +0000 |
commit | 0ff031c7f4e2c7fe1b671b30fef569eb3fbea942 (patch) | |
tree | 0493e9faf4bb9d69c06226901cea12f22714a92a /spec | |
parent | 7b8ec6e718331dd1f8330f08f49f01ba2c20b84c (diff) | |
download | gitlab-ce-0ff031c7f4e2c7fe1b671b30fef569eb3fbea942.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
5 files changed, 120 insertions, 154 deletions
diff --git a/spec/features/projects/jobs_spec.rb b/spec/features/projects/jobs_spec.rb index cebca338f33..458c67760d5 100644 --- a/spec/features/projects/jobs_spec.rb +++ b/spec/features/projects/jobs_spec.rb @@ -534,7 +534,7 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do end it 'shows deployment message' do - expect(page).to have_content 'This job is the most recent deployment to production' + expect(page).to have_content 'This job is deployed to production' expect(find('.js-environment-link')['href']).to match("environments/#{environment.id}") end @@ -548,14 +548,14 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do end it 'shows the name of the cluster' do - expect(page).to have_content 'Cluster the-cluster was used' + expect(page).to have_content 'using cluster the-cluster' end context 'when the user is not able to view the cluster' do let(:user_access_level) { :developer } it 'includes only the name of the cluster without a link' do - expect(page).to have_content 'Cluster the-cluster was used' + expect(page).to have_content 'using cluster the-cluster' expect(page).not_to have_link 'the-cluster' end end @@ -623,8 +623,7 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do let!(:second_deployment) { create(:deployment, :success, environment: environment, deployable: second_build) } it 'shows deployment message' do - expected_text = 'This job is an out-of-date deployment ' \ - "to staging. View the most recent deployment ##{second_deployment.iid}." + expected_text = 'This job is an out-of-date deployment to staging. View the most recent deployment.' expect(page).to have_css('.environment-information', text: expected_text) end diff --git a/spec/features/protected_branches_spec.rb b/spec/features/protected_branches_spec.rb index 80937223016..36c5a116b66 100644 --- a/spec/features/protected_branches_spec.rb +++ b/spec/features/protected_branches_spec.rb @@ -92,7 +92,10 @@ describe 'Protected Branches', :js do set_protected_branch_name('some-branch') click_on "Protect" - within(".protected-branches-list") { expect(page).to have_content(commit.id[0..7]) } + within(".protected-branches-list") do + expect(page).not_to have_content("matching") + expect(page).not_to have_content("was deleted") + end end it "displays an error message if the named branch does not exist" do @@ -101,7 +104,7 @@ describe 'Protected Branches', :js do set_protected_branch_name('some-branch') click_on "Protect" - within(".protected-branches-list") { expect(page).to have_content('branch was deleted') } + within(".protected-branches-list") { expect(page).to have_content('Branch was deleted') } end end @@ -127,7 +130,6 @@ describe 'Protected Branches', :js do click_on "Protect" within(".protected-branches-list") do - expect(page).to have_content("Protected branch (2)") expect(page).to have_content("2 matching branches") end end diff --git a/spec/javascripts/jobs/components/environments_block_spec.js b/spec/javascripts/jobs/components/environments_block_spec.js index 4bbc5f5a348..64a59d659a7 100644 --- a/spec/javascripts/jobs/components/environments_block_spec.js +++ b/spec/javascripts/jobs/components/environments_block_spec.js @@ -2,6 +2,9 @@ import Vue from 'vue'; import component from '~/jobs/components/environments_block.vue'; import mountComponent from '../../helpers/vue_mount_component_helper'; +const TEST_CLUSTER_NAME = 'test_cluster'; +const TEST_CLUSTER_PATH = 'path/to/test_cluster'; + describe('Environments block', () => { const Component = Vue.extend(component); let vm; @@ -20,22 +23,53 @@ describe('Environments block', () => { const lastDeployment = { iid: 'deployment', deployable: { build_path: 'bar' } }; + const createEnvironmentWithLastDeployment = () => ({ + ...environment, + last_deployment: { ...lastDeployment }, + }); + + const createEnvironmentWithCluster = () => ({ + ...environment, + last_deployment: { + ...lastDeployment, + cluster: { name: TEST_CLUSTER_NAME, path: TEST_CLUSTER_PATH }, + }, + }); + + const createComponent = (deploymentStatus = {}) => { + vm = mountComponent(Component, { + deploymentStatus, + iconStatus: status, + }); + }; + + const findText = () => vm.$el.textContent.trim(); + const findJobDeploymentLink = () => vm.$el.querySelector('.js-job-deployment-link'); + const findEnvironmentLink = () => vm.$el.querySelector('.js-environment-link'); + const findClusterLink = () => vm.$el.querySelector('.js-job-cluster-link'); + afterEach(() => { vm.$destroy(); }); describe('with last deployment', () => { it('renders info for most recent deployment', () => { - vm = mountComponent(Component, { - deploymentStatus: { - status: 'last', - environment, - }, - iconStatus: status, + createComponent({ + status: 'last', + environment, }); - expect(vm.$el.textContent.trim()).toEqual( - 'This job is the most recent deployment to environment.', + expect(findText()).toEqual('This job is deployed to environment.'); + }); + + it('renders info with cluster', () => { + createComponent({ + status: 'last', + environment: createEnvironmentWithCluster(), + }); + + expect(findText()).toEqual( + `This job is deployed to environment using cluster ${TEST_CLUSTER_NAME}.`, ); }); }); @@ -43,133 +77,106 @@ describe('Environments block', () => { describe('with out of date deployment', () => { describe('with last deployment', () => { it('renders info for out date and most recent', () => { - vm = mountComponent(Component, { - deploymentStatus: { - status: 'out_of_date', - environment: Object.assign({}, environment, { - last_deployment: lastDeployment, - }), - }, - iconStatus: status, + createComponent({ + status: 'out_of_date', + environment: createEnvironmentWithLastDeployment(), }); - expect(vm.$el.textContent.trim()).toEqual( - 'This job is an out-of-date deployment to environment. View the most recent deployment #deployment.', + expect(findText()).toEqual( + 'This job is an out-of-date deployment to environment. View the most recent deployment.', ); - expect(vm.$el.querySelector('.js-job-deployment-link').getAttribute('href')).toEqual('bar'); + expect(findJobDeploymentLink().getAttribute('href')).toEqual('bar'); + }); + + it('renders info with cluster', () => { + createComponent({ + status: 'out_of_date', + environment: createEnvironmentWithCluster(), + }); + + expect(findText()).toEqual( + `This job is an out-of-date deployment to environment using cluster ${TEST_CLUSTER_NAME}. View the most recent deployment.`, + ); }); }); describe('without last deployment', () => { it('renders info about out of date deployment', () => { - vm = mountComponent(Component, { - deploymentStatus: { - status: 'out_of_date', - environment, - }, - iconStatus: status, + createComponent({ + status: 'out_of_date', + environment, }); - expect(vm.$el.textContent.trim()).toEqual( - 'This job is an out-of-date deployment to environment.', - ); + expect(findText()).toEqual('This job is an out-of-date deployment to environment.'); }); }); }); describe('with failed deployment', () => { it('renders info about failed deployment', () => { - vm = mountComponent(Component, { - deploymentStatus: { - status: 'failed', - environment, - }, - iconStatus: status, + createComponent({ + status: 'failed', + environment, }); - expect(vm.$el.textContent.trim()).toEqual( - 'The deployment of this job to environment did not succeed.', - ); + expect(findText()).toEqual('The deployment of this job to environment did not succeed.'); }); }); describe('creating deployment', () => { describe('with last deployment', () => { it('renders info about creating deployment and overriding latest deployment', () => { - vm = mountComponent(Component, { - deploymentStatus: { - status: 'creating', - environment: Object.assign({}, environment, { - last_deployment: lastDeployment, - }), - }, - iconStatus: status, + createComponent({ + status: 'creating', + environment: createEnvironmentWithLastDeployment(), }); - expect(vm.$el.textContent.trim()).toEqual( - 'This job is creating a deployment to environment and will overwrite the latest deployment.', + expect(findText()).toEqual( + 'This job is creating a deployment to environment. This will overwrite the latest deployment.', ); - expect(vm.$el.querySelector('.js-job-deployment-link').getAttribute('href')).toEqual('bar'); + expect(findJobDeploymentLink().getAttribute('href')).toEqual('bar'); + expect(findEnvironmentLink().getAttribute('href')).toEqual(environment.environment_path); + expect(findClusterLink()).toBeNull(); }); }); describe('without last deployment', () => { it('renders info about failed deployment', () => { - vm = mountComponent(Component, { - deploymentStatus: { - status: 'creating', - environment, - }, - iconStatus: status, + createComponent({ + status: 'creating', + environment, }); - expect(vm.$el.textContent.trim()).toEqual( - 'This job is creating a deployment to environment.', - ); + expect(findText()).toEqual('This job is creating a deployment to environment.'); }); }); describe('without environment', () => { it('does not render environment link', () => { - vm = mountComponent(Component, { - deploymentStatus: { - status: 'creating', - environment: null, - }, - iconStatus: status, + createComponent({ + status: 'creating', + environment: null, }); - expect(vm.$el.querySelector('.js-environment-link')).toBeNull(); + expect(findEnvironmentLink()).toBeNull(); }); }); }); describe('with a cluster', () => { it('renders the cluster link', () => { - const cluster = { - name: 'the-cluster', - path: '/the-cluster-path', - }; - vm = mountComponent(Component, { - deploymentStatus: { - status: 'last', - environment: Object.assign({}, environment, { - last_deployment: { - ...lastDeployment, - cluster, - }, - }), - }, - iconStatus: status, + createComponent({ + status: 'last', + environment: createEnvironmentWithCluster(), }); - expect(vm.$el.textContent.trim()).toContain('Cluster the-cluster was used.'); - - expect(vm.$el.querySelector('.js-job-cluster-link').getAttribute('href')).toEqual( - '/the-cluster-path', + expect(findText()).toEqual( + `This job is deployed to environment using cluster ${TEST_CLUSTER_NAME}.`, ); + + expect(findClusterLink().getAttribute('href')).toEqual(TEST_CLUSTER_PATH); }); describe('when the cluster is missing the path', () => { @@ -177,39 +184,20 @@ describe('Environments block', () => { const cluster = { name: 'the-cluster', }; - vm = mountComponent(Component, { - deploymentStatus: { - status: 'last', - environment: Object.assign({}, environment, { - last_deployment: { - ...lastDeployment, - cluster, - }, - }), - }, - iconStatus: status, - }); - - expect(vm.$el.textContent.trim()).toContain('Cluster the-cluster was used.'); - - expect(vm.$el.querySelector('.js-job-cluster-link')).toBeNull(); - }); - }); - }); - - describe('without a cluster', () => { - it('does not render a cluster link', () => { - vm = mountComponent(Component, { - deploymentStatus: { + createComponent({ status: 'last', environment: Object.assign({}, environment, { - last_deployment: lastDeployment, + last_deployment: { + ...lastDeployment, + cluster, + }, }), - }, - iconStatus: status, - }); + }); + + expect(findText()).toContain('using cluster the-cluster.'); - expect(vm.$el.querySelector('.js-job-cluster-link')).toBeNull(); + expect(findClusterLink()).toBeNull(); + }); }); }); }); diff --git a/spec/models/concerns/atomic_internal_id_spec.rb b/spec/models/concerns/atomic_internal_id_spec.rb index 80f296d8825..0605392c0aa 100644 --- a/spec/models/concerns/atomic_internal_id_spec.rb +++ b/spec/models/concerns/atomic_internal_id_spec.rb @@ -22,41 +22,22 @@ describe AtomicInternalId do end context 'when value is set by ensure_project_iid!' do - context 'with iid_always_track false' do - before do - stub_feature_flags(iid_always_track: false) - end + it 'does not track the value' do + expect(InternalId).not_to receive(:track_greatest) - it 'does not track the value' do - expect(InternalId).not_to receive(:track_greatest) - - milestone.ensure_project_iid! - subject - end - - it 'tracks the iid for the scope that is actually present' do - milestone.iid = external_iid - - expect(InternalId).to receive(:track_greatest).once.with(milestone, scope_attrs, usage, external_iid, anything) - expect(InternalId).not_to receive(:generate_next) - - # group scope is not present here, the milestone does not have a group - milestone.track_group_iid! - subject - end + milestone.ensure_project_iid! + subject end - context 'with iid_always_track enabled' do - before do - stub_feature_flags(iid_always_track: true) - end + it 'tracks the iid for the scope that is actually present' do + milestone.iid = external_iid - it 'does not track the value' do - expect(InternalId).to receive(:track_greatest) + expect(InternalId).to receive(:track_greatest).once.with(milestone, scope_attrs, usage, external_iid, anything) + expect(InternalId).not_to receive(:generate_next) - milestone.ensure_project_iid! - subject - end + # group scope is not present here, the milestone does not have a group + milestone.track_group_iid! + subject end end end diff --git a/spec/support/shared_examples/models/atomic_internal_id_shared_examples.rb b/spec/support/shared_examples/models/atomic_internal_id_shared_examples.rb index 44f66ff47f4..b837ca87256 100644 --- a/spec/support/shared_examples/models/atomic_internal_id_shared_examples.rb +++ b/spec/support/shared_examples/models/atomic_internal_id_shared_examples.rb @@ -47,10 +47,6 @@ shared_examples_for 'AtomicInternalId' do |validate_presence: true| end describe 'internal id generation' do - before do - stub_feature_flags(iid_always_track: false) - end - subject { instance.save! } it 'calls InternalId.generate_next and sets internal id attribute' do |