Wrap group removal into service
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
79aac2c128
commit
61cfd1d273
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue