diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-05 00:09:41 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-05 00:09:41 +0300 |
commit | b3cd77e90438a6c6e837dc27627d4c76f85ecd29 (patch) | |
tree | 52bbe45c9fd2aaceaca613bce04e7aab4a8aa07b /spec | |
parent | 9bbcab8301ed38576debcb6a7f07f99005ff805a (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/factories/users.rb | 4 | ||||
-rw-r--r-- | spec/frontend/pipelines/pipeline_details_mediator_spec.js (renamed from spec/javascripts/pipelines/pipeline_details_mediator_spec.js) | 8 | ||||
-rw-r--r-- | spec/frontend/static_site_editor/pages/home_spec.js (renamed from spec/frontend/static_site_editor/components/static_site_editor_spec.js) | 6 | ||||
-rw-r--r-- | spec/frontend/vue_shared/components/__snapshots__/clone_dropdown_spec.js.snap | 22 | ||||
-rw-r--r-- | spec/models/concerns/has_user_type_spec.rb | 4 | ||||
-rw-r--r-- | spec/models/user_spec.rb | 16 | ||||
-rw-r--r-- | spec/policies/global_policy_spec.rb | 31 | ||||
-rw-r--r-- | spec/views/admin/users/_user.html.haml_spec.rb | 10 |
8 files changed, 76 insertions, 25 deletions
diff --git a/spec/factories/users.rb b/spec/factories/users.rb index e834cd13d36..2f5cc404143 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -31,6 +31,10 @@ FactoryBot.define do user_type { :project_bot } end + trait :migration_bot do + user_type { :migration_bot } + end + trait :external do external { true } end diff --git a/spec/javascripts/pipelines/pipeline_details_mediator_spec.js b/spec/frontend/pipelines/pipeline_details_mediator_spec.js index 61ee2dc13ca..083e97666ed 100644 --- a/spec/javascripts/pipelines/pipeline_details_mediator_spec.js +++ b/spec/frontend/pipelines/pipeline_details_mediator_spec.js @@ -1,6 +1,7 @@ import MockAdapter from 'axios-mock-adapter'; import axios from '~/lib/utils/axios_utils'; import PipelineMediator from '~/pipelines/pipeline_details_mediator'; +import waitForPromises from 'helpers/wait_for_promises'; describe('PipelineMdediator', () => { let mediator; @@ -23,14 +24,13 @@ describe('PipelineMdediator', () => { }); describe('request and store data', () => { - it('should store received data', done => { + it('should store received data', () => { mock.onGet('foo.json').reply(200, { id: '121123' }); mediator.fetchPipeline(); - setTimeout(() => { + return waitForPromises().then(() => { expect(mediator.store.state.pipeline).toEqual({ id: '121123' }); - done(); - }, 0); + }); }); }); }); diff --git a/spec/frontend/static_site_editor/components/static_site_editor_spec.js b/spec/frontend/static_site_editor/pages/home_spec.js index 5d4e3758557..82e39447ae6 100644 --- a/spec/frontend/static_site_editor/components/static_site_editor_spec.js +++ b/spec/frontend/static_site_editor/pages/home_spec.js @@ -4,7 +4,7 @@ import { GlSkeletonLoader } from '@gitlab/ui'; import createState from '~/static_site_editor/store/state'; -import StaticSiteEditor from '~/static_site_editor/components/static_site_editor.vue'; +import Home from '~/static_site_editor/pages/home.vue'; import EditArea from '~/static_site_editor/components/edit_area.vue'; import EditHeader from '~/static_site_editor/components/edit_header.vue'; import InvalidContentMessage from '~/static_site_editor/components/invalid_content_message.vue'; @@ -24,7 +24,7 @@ const localVue = createLocalVue(); localVue.use(Vuex); -describe('StaticSiteEditor', () => { +describe('static_site_editor/pages/home', () => { let wrapper; let store; let loadContentActionMock; @@ -68,7 +68,7 @@ describe('StaticSiteEditor', () => { }; const buildWrapper = () => { - wrapper = shallowMount(StaticSiteEditor, { + wrapper = shallowMount(Home, { localVue, store, }); diff --git a/spec/frontend/vue_shared/components/__snapshots__/clone_dropdown_spec.js.snap b/spec/frontend/vue_shared/components/__snapshots__/clone_dropdown_spec.js.snap index 4cd03a690e9..7dd324a61cd 100644 --- a/spec/frontend/vue_shared/components/__snapshots__/clone_dropdown_spec.js.snap +++ b/spec/frontend/vue_shared/components/__snapshots__/clone_dropdown_spec.js.snap @@ -44,18 +44,13 @@ exports[`Clone Dropdown Button rendering matches the snapshot 1`] = ` > <gl-button-stub category="tertiary" + class="d-inline-flex" data-clipboard-text="ssh://foo.bar" - icon="" + icon="copy-to-clipboard" size="medium" title="Copy URL" variant="default" - > - <gl-icon-stub - name="copy-to-clipboard" - size="16" - title="Copy URL" - /> - </gl-button-stub> + /> </b-input-group-append-stub> </b-input-group-stub> </div> @@ -94,18 +89,13 @@ exports[`Clone Dropdown Button rendering matches the snapshot 1`] = ` > <gl-button-stub category="tertiary" + class="d-inline-flex" data-clipboard-text="http://foo.bar" - icon="" + icon="copy-to-clipboard" size="medium" title="Copy URL" variant="default" - > - <gl-icon-stub - name="copy-to-clipboard" - size="16" - title="Copy URL" - /> - </gl-button-stub> + /> </b-input-group-append-stub> </b-input-group-stub> </div> diff --git a/spec/models/concerns/has_user_type_spec.rb b/spec/models/concerns/has_user_type_spec.rb index cf12f263bd7..7ec29dde57b 100644 --- a/spec/models/concerns/has_user_type_spec.rb +++ b/spec/models/concerns/has_user_type_spec.rb @@ -4,8 +4,8 @@ require 'spec_helper' describe User do specify 'types consistency checks', :aggregate_failures do - expect(described_class::USER_TYPES) - .to include(*%i[human ghost alert_bot project_bot support_bot service_user visual_review_bot]) + expect(described_class::USER_TYPES.keys) + .to match_array(%w[human ghost alert_bot project_bot support_bot service_user visual_review_bot migration_bot]) expect(described_class::USER_TYPES).to include(*described_class::BOT_USER_TYPES) expect(described_class::USER_TYPES).to include(*described_class::NON_INTERNAL_USER_TYPES) expect(described_class::USER_TYPES).to include(*described_class::INTERNAL_USER_TYPES) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index b05311814d0..7649b09aa8e 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -4584,4 +4584,20 @@ describe User, :do_not_mock_admin_mode do it_behaves_like 'does not require password to be present' end end + + describe '#migration_bot' do + it 'creates the user if it does not exist' do + expect do + described_class.migration_bot + end.to change { User.where(user_type: :migration_bot).count }.by(1) + end + + it 'does not create a new user if it already exists' do + described_class.migration_bot + + expect do + described_class.migration_bot + end.not_to change { User.count } + end + end end diff --git a/spec/policies/global_policy_spec.rb b/spec/policies/global_policy_spec.rb index ac7f5db980c..bd0722ce20a 100644 --- a/spec/policies/global_policy_spec.rb +++ b/spec/policies/global_policy_spec.rb @@ -6,6 +6,7 @@ describe GlobalPolicy do include TermsHelper let_it_be(:project_bot) { create(:user, :project_bot) } + let_it_be(:migration_bot) { create(:user, :migration_bot) } let(:current_user) { create(:user) } let(:user) { create(:user) } @@ -155,6 +156,12 @@ describe GlobalPolicy do it { is_expected.to be_allowed(:access_api) } end + context 'migration bot' do + let(:current_user) { migration_bot } + + it { is_expected.not_to be_allowed(:access_api) } + end + context 'when terms are enforced' do before do enforce_terms @@ -244,6 +251,12 @@ describe GlobalPolicy do it { is_expected.not_to be_allowed(:receive_notifications) } end + + context 'migration bot' do + let(:current_user) { migration_bot } + + it { is_expected.not_to be_allowed(:receive_notifications) } + end end describe 'git access' do @@ -263,6 +276,12 @@ describe GlobalPolicy do it { is_expected.to be_allowed(:access_git) } end + context 'migration bot' do + let(:current_user) { migration_bot } + + it { is_expected.to be_allowed(:access_git) } + end + describe 'deactivated user' do before do current_user.deactivate @@ -414,6 +433,12 @@ describe GlobalPolicy do it { is_expected.to be_allowed(:use_slash_commands) } end + + context 'migration bot' do + let(:current_user) { migration_bot } + + it { is_expected.not_to be_allowed(:use_slash_commands) } + end end describe 'create_snippet' do @@ -440,5 +465,11 @@ describe GlobalPolicy do it { is_expected.not_to be_allowed(:log_in) } end + + context 'migration bot' do + let(:current_user) { migration_bot } + + it { is_expected.not_to be_allowed(:log_in) } + end end end diff --git a/spec/views/admin/users/_user.html.haml_spec.rb b/spec/views/admin/users/_user.html.haml_spec.rb index 0eaaa2d5304..de5a291a6f8 100644 --- a/spec/views/admin/users/_user.html.haml_spec.rb +++ b/spec/views/admin/users/_user.html.haml_spec.rb @@ -27,6 +27,16 @@ describe 'admin/users/_user.html.haml' do expect(rendered).not_to have_selector('.table-action-buttons') end end + + context 'when showing a `Migration User`' do + let(:user) { create(:user, user_type: :migration_bot) } + + it 'does not render action buttons' do + render + + expect(rendered).not_to have_selector('.table-action-buttons') + end + end end context 'when showing an external user' do |