Wrap group removal into service

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
Dmitriy Zaporozhets 2015-06-03 14:07:20 +02:00
parent 79aac2c128
commit 61cfd1d273
No known key found for this signature in database
GPG Key ID: 627C5F589F467F17
4 changed files with 14 additions and 3 deletions

View File

@ -47,7 +47,7 @@ class Admin::GroupsController < Admin::ApplicationController
end
def destroy
@group.destroy
DestroyGroupService.new(@group, current_user).execute
redirect_to admin_groups_path, notice: 'Group was successfully deleted.'
end

View File

@ -82,7 +82,7 @@ class GroupsController < Groups::ApplicationController
end
def destroy
@group.destroy
DestroyGroupService.new(@group, current_user).execute
redirect_to root_path, notice: 'Group was removed.'
end

View File

@ -0,0 +1,11 @@
class DestroyGroupService
attr_accessor :group, :current_user
def initialize(group, user)
@group, @current_user = group, user
end
def execute
@group.destroy
end
end

View File

@ -62,7 +62,7 @@ module API
delete ":id" do
group = find_group(params[:id])
authorize! :admin_group, group
group.destroy
DestroyGroupService.new(group, current_user).execute
end
# Transfer a project to the Group namespace