diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
commit | 7021455bd1ed7b125c55eb1b33c5a01f2bc55ee0 (patch) | |
tree | 5bdc2229f5198d516781f8d24eace62fc7e589e9 /spec/services/members/destroy_service_spec.rb | |
parent | 185b095e93520f96e9cfc31d9c3e69b498cdab7c (diff) |
Add latest changes from gitlab-org/gitlab@15-6-stable-eev15.6.0-rc42
Diffstat (limited to 'spec/services/members/destroy_service_spec.rb')
-rw-r--r-- | spec/services/members/destroy_service_spec.rb | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/spec/services/members/destroy_service_spec.rb b/spec/services/members/destroy_service_spec.rb index 8559c02be57..d0f009f1321 100644 --- a/spec/services/members/destroy_service_spec.rb +++ b/spec/services/members/destroy_service_spec.rb @@ -77,7 +77,7 @@ RSpec.describe Members::DestroyService do end end - shared_examples 'a service destroying an access requester' do + shared_examples 'a service destroying an access request of another user' do it_behaves_like 'a service destroying a member' it 'calls Member#after_decline_request' do @@ -85,12 +85,16 @@ RSpec.describe Members::DestroyService do described_class.new(current_user).execute(member, **opts) end + end + + shared_examples 'a service destroying an access request of self' do + it_behaves_like 'a service destroying a member' context 'when current user is the member' do it 'does not call Member#after_decline_request' do expect_any_instance_of(NotificationService).not_to receive(:decline_access_request).with(member) - described_class.new(member_user).execute(member, **opts) + described_class.new(current_user).execute(member, **opts) end end end @@ -277,11 +281,24 @@ RSpec.describe Members::DestroyService do group.add_owner(current_user) end - it_behaves_like 'a service destroying an access requester' do + it_behaves_like 'a service destroying an access request of another user' do + let(:member) { group_project.requesters.find_by(user_id: member_user.id) } + end + + it_behaves_like 'a service destroying an access request of another user' do + let(:member) { group.requesters.find_by(user_id: member_user.id) } + end + end + + context 'on withdrawing their own access request' do + let(:opts) { { skip_subresources: true } } + let(:current_user) { member_user } + + it_behaves_like 'a service destroying an access request of self' do let(:member) { group_project.requesters.find_by(user_id: member_user.id) } end - it_behaves_like 'a service destroying an access requester' do + it_behaves_like 'a service destroying an access request of self' do let(:member) { group.requesters.find_by(user_id: member_user.id) } end end |