diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-17 18:08:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-17 18:08:36 +0300 |
commit | c61d90dbfa0a7cb58b758ed07a9d0b5406beb61e (patch) | |
tree | 5c29d476a605417c370997caf3dabe8e8270b8be /spec/workers | |
parent | a89912871cb169249d3ddc2ed59326d47ecdae82 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers')
-rw-r--r-- | spec/workers/authorized_project_update/project_create_worker_spec.rb | 2 | ||||
-rw-r--r-- | spec/workers/authorized_project_update/project_group_link_create_worker_spec.rb | 52 |
2 files changed, 53 insertions, 1 deletions
diff --git a/spec/workers/authorized_project_update/project_create_worker_spec.rb b/spec/workers/authorized_project_update/project_create_worker_spec.rb index 5ebfb60bc79..10d6d58ee7a 100644 --- a/spec/workers/authorized_project_update/project_create_worker_spec.rb +++ b/spec/workers/authorized_project_update/project_create_worker_spec.rb @@ -27,7 +27,7 @@ describe AuthorizedProjectUpdate::ProjectCreateWorker do context 'idempotence' do before do - create(:group_member, access_level: Gitlab::Access::MAINTAINER, group: group, user: group_user) + create(:group_member, access_level: access_level, group: group, user: group_user) ProjectAuthorization.delete_all end diff --git a/spec/workers/authorized_project_update/project_group_link_create_worker_spec.rb b/spec/workers/authorized_project_update/project_group_link_create_worker_spec.rb new file mode 100644 index 00000000000..9d82e9f338d --- /dev/null +++ b/spec/workers/authorized_project_update/project_group_link_create_worker_spec.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe AuthorizedProjectUpdate::ProjectGroupLinkCreateWorker do + let_it_be(:group) { create(:group, :private) } + let_it_be(:group_project) { create(:project, group: group) } + let_it_be(:shared_with_group) { create(:group, :private) } + let_it_be(:user) { create(:user) } + + let(:access_level) { Gitlab::Access::MAINTAINER } + + subject(:worker) { described_class.new } + + it 'calls AuthorizedProjectUpdate::ProjectCreateService' do + expect_next_instance_of(AuthorizedProjectUpdate::ProjectGroupLinkCreateService) do |service| + expect(service).to(receive(:execute)) + end + + worker.perform(group_project.id, shared_with_group.id) + end + + it 'returns ServiceResponse.success' do + result = worker.perform(group_project.id, shared_with_group.id) + + expect(result.success?).to be_truthy + end + + context 'idempotence' do + before do + create(:group_member, group: shared_with_group, user: user, access_level: access_level) + create(:project_group_link, project: group_project, group: shared_with_group) + ProjectAuthorization.delete_all + end + + include_examples 'an idempotent worker' do + let(:job_args) { [group_project.id, shared_with_group.id] } + + it 'creates project authorization' do + subject + + project_authorization = ProjectAuthorization.where( + project_id: group_project.id, + user_id: user.id, + access_level: access_level) + + expect(project_authorization).to exist + expect(ProjectAuthorization.count).to eq(1) + end + end + end +end |