diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-10 12:10:24 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-10 12:10:24 +0000 |
commit | e55ef824f5da702b2e1e3edac0115ce5538927e9 (patch) | |
tree | a93ce00fbf4440c95d582d530855d88c7b4e70bc /spec/services/members | |
parent | c1d4ac251994b4463fb0cfcc263af26ded0d8eac (diff) | |
download | gitlab-ce-e55ef824f5da702b2e1e3edac0115ce5538927e9.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/members')
-rw-r--r-- | spec/services/members/destroy_service_spec.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/services/members/destroy_service_spec.rb b/spec/services/members/destroy_service_spec.rb index 9f0daba3327..8559c02be57 100644 --- a/spec/services/members/destroy_service_spec.rb +++ b/spec/services/members/destroy_service_spec.rb @@ -95,6 +95,37 @@ RSpec.describe Members::DestroyService do end end + context 'With ExclusiveLeaseHelpers' do + let(:service_object) { described_class.new(current_user) } + let!(:member) { group_project.add_developer(member_user) } + + subject(:destroy_member) { service_object.execute(member, **opts) } + + before do + group_project.add_maintainer(current_user) + + allow(service_object).to receive(:in_lock) do |_, &block| + block.call if lock_obtained + end + end + + context 'when lock is obtained' do + let(:lock_obtained) { true } + + it 'destroys the membership' do + expect { destroy_member }.to change { group_project.members.count }.by(-1) + end + end + + context 'when the lock can not be obtained' do + let(:lock_obtained) { false } + + it 'does not destroy the membership' do + expect { destroy_member }.not_to change { group_project.members.count } + end + end + end + context 'with a member with access' do before do group_project.update_attribute(:visibility_level, Gitlab::VisibilityLevel::PRIVATE) |