diff options
author | Adam Niedzielski <adamsunday@gmail.com> | 2016-08-05 00:34:57 +0300 |
---|---|---|
committer | Adam Niedzielski <adamsunday@gmail.com> | 2016-08-05 00:34:57 +0300 |
commit | b4b51441aa096db9f953eb8e907dd68e75227c62 (patch) | |
tree | 7d04576c58a253fd17f7c1b171131e46d5cee265 /app | |
parent | 9adddebc6deacd05e2de146ede640f690a17d7bf (diff) |
Extract Members::AuthorizedDestroyService from Members::DestroyService.
Diffstat (limited to 'app')
-rw-r--r-- | app/services/members/authorized_destroy_service.rb | 17 | ||||
-rw-r--r-- | app/services/members/destroy_service.rb | 7 |
2 files changed, 18 insertions, 6 deletions
diff --git a/app/services/members/authorized_destroy_service.rb b/app/services/members/authorized_destroy_service.rb new file mode 100644 index 00000000000..c23f90a6a10 --- /dev/null +++ b/app/services/members/authorized_destroy_service.rb @@ -0,0 +1,17 @@ +module Members + class AuthorizedDestroyService < BaseService + attr_accessor :member, :user + + def initialize(member, user = nil) + @member, @user = member, user + end + + def execute + member.destroy + + if member.request? && member.user != user + notification_service.decline_access_request(member) + end + end + end +end diff --git a/app/services/members/destroy_service.rb b/app/services/members/destroy_service.rb index 15358f80208..5228da4d457 100644 --- a/app/services/members/destroy_service.rb +++ b/app/services/members/destroy_service.rb @@ -10,12 +10,7 @@ module Members unless member && can?(current_user, "destroy_#{member.type.underscore}".to_sym, member) raise Gitlab::Access::AccessDeniedError end - - member.destroy - - if member.request? && member.user != current_user - notification_service.decline_access_request(member) - end + AuthorizedDestroyService.new(member, current_user).execute end end end |