diff options
Diffstat (limited to 'spec/models/members/project_member_spec.rb')
-rw-r--r-- | spec/models/members/project_member_spec.rb | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/spec/models/members/project_member_spec.rb b/spec/models/members/project_member_spec.rb index 8c989f5aaca..39d9d25a98c 100644 --- a/spec/models/members/project_member_spec.rb +++ b/spec/models/members/project_member_spec.rb @@ -111,12 +111,12 @@ RSpec.describe ProjectMember do end end - describe '.add_users_to_projects' do + describe '.add_members_to_projects' do it 'adds the given users to the given projects' do projects = create_list(:project, 2) users = create_list(:user, 2) - described_class.add_users_to_projects( + described_class.add_members_to_projects( [projects.first.id, projects.second.id], [users.first.id, users.second], described_class::MAINTAINER) @@ -174,8 +174,8 @@ RSpec.describe ProjectMember do expect { project.destroy! }.to change { user.can?(:guest_access, project) }.from(true).to(false) end - it 'refreshes the authorization without calling AuthorizedProjectUpdate::ProjectRecalculatePerUserService' do - expect(AuthorizedProjectUpdate::ProjectRecalculatePerUserService).not_to receive(:new) + it 'refreshes the authorization without calling AuthorizedProjectUpdate::ProjectRecalculatePerUserWorker' do + expect(AuthorizedProjectUpdate::ProjectRecalculatePerUserWorker).not_to receive(:bulk_perform_and_wait) project.destroy! end @@ -199,7 +199,7 @@ RSpec.describe ProjectMember do context 'when importing' do it 'does not refresh' do - expect(AuthorizedProjectUpdate::ProjectRecalculatePerUserService).not_to receive(:new) + expect(AuthorizedProjectUpdate::ProjectRecalculatePerUserWorker).not_to receive(:bulk_perform_and_wait) member = build(:project_member) member.importing = true @@ -212,11 +212,11 @@ RSpec.describe ProjectMember do let_it_be(:project) { create(:project) } let_it_be(:user) { create(:user) } - shared_examples_for 'calls AuthorizedProjectUpdate::ProjectRecalculatePerUserService to recalculate authorizations' do - it 'calls AuthorizedProjectUpdate::ProjectRecalculatePerUserService' do - expect_next_instance_of(AuthorizedProjectUpdate::ProjectRecalculatePerUserService, project, user) do |service| - expect(service).to receive(:execute) - end + shared_examples_for 'calls AuthorizedProjectUpdate::ProjectRecalculatePerUserWorker inline to recalculate authorizations' do + it 'calls AuthorizedProjectUpdate::ProjectRecalculatePerUserWorker' do + expect(AuthorizedProjectUpdate::ProjectRecalculatePerUserWorker).to receive(:bulk_perform_and_wait).with( + [[project.id, user.id]] + ) action end @@ -236,13 +236,13 @@ RSpec.describe ProjectMember do end context 'on create' do - let(:action) { project.add_user(user, Gitlab::Access::GUEST) } + let(:action) { project.add_member(user, Gitlab::Access::GUEST) } it 'changes access level' do expect { action }.to change { user.can?(:guest_access, project) }.from(false).to(true) end - it_behaves_like 'calls AuthorizedProjectUpdate::ProjectRecalculatePerUserService to recalculate authorizations' + it_behaves_like 'calls AuthorizedProjectUpdate::ProjectRecalculatePerUserWorker inline to recalculate authorizations' it_behaves_like 'calls AuthorizedProjectUpdate::UserRefreshFromReplicaWorker with a delay to update project authorizations' end @@ -250,14 +250,14 @@ RSpec.describe ProjectMember do let(:action) { project.members.find_by(user: user).update!(access_level: Gitlab::Access::DEVELOPER) } before do - project.add_user(user, Gitlab::Access::GUEST) + project.add_member(user, Gitlab::Access::GUEST) end it 'changes access level' do expect { action }.to change { user.can?(:developer_access, project) }.from(false).to(true) end - it_behaves_like 'calls AuthorizedProjectUpdate::ProjectRecalculatePerUserService to recalculate authorizations' + it_behaves_like 'calls AuthorizedProjectUpdate::ProjectRecalculatePerUserWorker inline to recalculate authorizations' it_behaves_like 'calls AuthorizedProjectUpdate::UserRefreshFromReplicaWorker with a delay to update project authorizations' end @@ -265,7 +265,7 @@ RSpec.describe ProjectMember do let(:action) { project.members.find_by(user: user).destroy! } before do - project.add_user(user, Gitlab::Access::GUEST) + project.add_member(user, Gitlab::Access::GUEST) end it 'changes access level', :sidekiq_inline do |