diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 17:34:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 17:34:42 +0300 |
commit | 9f46488805e86b1bc341ea1620b866016c2ce5ed (patch) | |
tree | f9748c7e287041e37d6da49e0a29c9511dc34768 /spec/workers/authorized_project_update | |
parent | dfc92d081ea0332d69c8aca2f0e745cb48ae5e6d (diff) |
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'spec/workers/authorized_project_update')
-rw-r--r-- | spec/workers/authorized_project_update/project_create_worker_spec.rb | 50 | ||||
-rw-r--r-- | spec/workers/authorized_project_update/user_refresh_with_low_urgency_worker_spec.rb | 11 |
2 files changed, 61 insertions, 0 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 new file mode 100644 index 00000000000..5ebfb60bc79 --- /dev/null +++ b/spec/workers/authorized_project_update/project_create_worker_spec.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe AuthorizedProjectUpdate::ProjectCreateWorker do + let_it_be(:group) { create(:group, :private) } + let_it_be(:group_project) { create(:project, group: group) } + let_it_be(:group_user) { create(:user) } + + let(:access_level) { Gitlab::Access::MAINTAINER } + + subject(:worker) { described_class.new } + + it 'calls AuthorizedProjectUpdate::ProjectCreateService' do + expect_next_instance_of(AuthorizedProjectUpdate::ProjectCreateService) do |service| + expect(service).to(receive(:execute)) + end + + worker.perform(group_project.id) + end + + it 'returns ServiceResponse.success' do + result = worker.perform(group_project.id) + + expect(result.success?).to be_truthy + end + + context 'idempotence' do + before do + create(:group_member, access_level: Gitlab::Access::MAINTAINER, group: group, user: group_user) + ProjectAuthorization.delete_all + end + + include_examples 'an idempotent worker' do + let(:job_args) { group_project.id } + + it 'creates project authorization' do + subject + + project_authorization = ProjectAuthorization.where( + project_id: group_project.id, + user_id: group_user.id, + access_level: access_level) + + expect(project_authorization).to exist + expect(ProjectAuthorization.count).to eq(1) + end + end + end +end diff --git a/spec/workers/authorized_project_update/user_refresh_with_low_urgency_worker_spec.rb b/spec/workers/authorized_project_update/user_refresh_with_low_urgency_worker_spec.rb new file mode 100644 index 00000000000..fa029dae0fa --- /dev/null +++ b/spec/workers/authorized_project_update/user_refresh_with_low_urgency_worker_spec.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe AuthorizedProjectUpdate::UserRefreshWithLowUrgencyWorker do + it 'is labeled as low urgency' do + expect(described_class.get_urgency).to eq(:low) + end + + it_behaves_like "refreshes user's project authorizations" +end |