Commit 61cfd1d2 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Wrap group removal into service

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 79aac2c1
......@@ -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
......
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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment