Commit 890ffac6 authored by Yorick Peterse's avatar Yorick Peterse

Use a method for creating groups in the API

EE has some custom behaviour that needs to run before and after creating
a group in the API. By moving the group creation logic to a separate
method, EE can easily extend this behaviour; without having to directly
modify the API source code.
parent 654c4dd9
......@@ -58,6 +58,14 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
def create_group
# This is a separate method so that EE can extend its behaviour, without
# having to modify this code directly.
::Groups::CreateService
.new(current_user, declared_params(include_missing: false))
.execute
end
def find_group_projects(params)
group = find_group!(params[:id])
options = {
......@@ -127,7 +135,7 @@ module API
authorize! :create_group
end
group = ::Groups::CreateService.new(current_user, declared_params(include_missing: false)).execute
group = create_group
if group.persisted?
present group, with: Entities::GroupDetail, current_user: current_user
......
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