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
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@group.destroy
|
DestroyGroupService.new(@group, current_user).execute
|
||||||
|
|
||||||
redirect_to admin_groups_path, notice: 'Group was successfully deleted.'
|
redirect_to admin_groups_path, notice: 'Group was successfully deleted.'
|
||||||
end
|
end
|
||||||
|
|
|
@ -82,7 +82,7 @@ class GroupsController < Groups::ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@group.destroy
|
DestroyGroupService.new(@group, current_user).execute
|
||||||
|
|
||||||
redirect_to root_path, notice: 'Group was removed.'
|
redirect_to root_path, notice: 'Group was removed.'
|
||||||
end
|
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
|
delete ":id" do
|
||||||
group = find_group(params[:id])
|
group = find_group(params[:id])
|
||||||
authorize! :admin_group, group
|
authorize! :admin_group, group
|
||||||
group.destroy
|
DestroyGroupService.new(group, current_user).execute
|
||||||
end
|
end
|
||||||
|
|
||||||
# Transfer a project to the Group namespace
|
# Transfer a project to the Group namespace
|
||||||
|
|
Loading…
Reference in New Issue