diff options
-rw-r--r-- | app/services/members/destroy_service.rb | 4 | ||||
-rw-r--r-- | spec/services/members/destroy_service_spec.rb | 8 |
2 files changed, 11 insertions, 1 deletions
diff --git a/app/services/members/destroy_service.rb b/app/services/members/destroy_service.rb index e32eb47b846..59a55e42e38 100644 --- a/app/services/members/destroy_service.rb +++ b/app/services/members/destroy_service.rb @@ -10,7 +10,9 @@ module Members if can?(current_user, "destroy_#{member.type.underscore}".to_sym, member) member.destroy - notification_service.decline_access_request(member) if member.request? + if member.request? && member.user != current_user + notification_service.decline_access_request(member) + end end member diff --git a/spec/services/members/destroy_service_spec.rb b/spec/services/members/destroy_service_spec.rb index aa002b4bd22..04c2782c125 100644 --- a/spec/services/members/destroy_service_spec.rb +++ b/spec/services/members/destroy_service_spec.rb @@ -34,6 +34,14 @@ describe Members::DestroyService, services: true do destroy_member(member, user) end + + 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) + + destroy_member(member, member.user) + end + end end end |