diff options
author | Rémy Coutable <remy@rymai.me> | 2016-09-09 19:51:31 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-10-03 17:57:48 +0300 |
commit | c8b1311934935c7ac7fd901558e19ac496fbad2c (patch) | |
tree | 53760b417a85f51b76ee21a343834b20bc45ede3 /app/services | |
parent | 3158f57dba6dcef3e586ae8fced7deb6fdbd6dc0 (diff) |
Fix a few things after the initial improvment to Members::DestroyService
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/members/authorized_destroy_service.rb | 2 | ||||
-rw-r--r-- | app/services/members/destroy_service.rb | 11 |
2 files changed, 8 insertions, 5 deletions
diff --git a/app/services/members/authorized_destroy_service.rb b/app/services/members/authorized_destroy_service.rb index ca9db59cac7..b7a244c2029 100644 --- a/app/services/members/authorized_destroy_service.rb +++ b/app/services/members/authorized_destroy_service.rb @@ -14,6 +14,8 @@ module Members if member.request? && member.user != user notification_service.decline_access_request(member) end + + member end end end diff --git a/app/services/members/destroy_service.rb b/app/services/members/destroy_service.rb index b3d79d577bd..ee072065523 100644 --- a/app/services/members/destroy_service.rb +++ b/app/services/members/destroy_service.rb @@ -15,7 +15,7 @@ module Members def execute(scope = :members) raise "scope :#{scope} is not allowed!" unless ALLOWED_SCOPES.include?(scope) - member = find_member(scope) + member = find_member!(scope) raise Gitlab::Access::AccessDeniedError if cannot_destroy_member?(member) @@ -24,13 +24,14 @@ module Members private - def find_member(scope) + def find_member!(scope) + condition = params[:user_id] ? { user_id: params[:user_id] } : { id: params[:id] } case scope when :all - source.members.find_by(user_id: params[:user_id]) || - source.requesters.find_by!(user_id: params[:user_id]) + source.members.find_by(condition) || + source.requesters.find_by!(condition) else - source.public_send(scope).find_by!(user_id: params[:user_id]) + source.public_send(scope).find_by!(condition) end end |