summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Niedzielski <adamsunday@gmail.com>2016-08-04 23:34:57 +0200
committerAdam Niedzielski <adamsunday@gmail.com>2016-08-04 23:34:57 +0200
commitb4b51441aa096db9f953eb8e907dd68e75227c62 (patch)
tree7d04576c58a253fd17f7c1b171131e46d5cee265
parent9adddebc6deacd05e2de146ede640f690a17d7bf (diff)
downloadgitlab-ce-b4b51441aa096db9f953eb8e907dd68e75227c62.tar.gz
Extract Members::AuthorizedDestroyService from Members::DestroyService.
-rw-r--r--app/services/members/authorized_destroy_service.rb17
-rw-r--r--app/services/members/destroy_service.rb7
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