summaryrefslogtreecommitdiff
path: root/lib/api
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2019-02-25 15:01:34 +0100
committerYorick Peterse <yorickpeterse@gmail.com>2019-03-04 17:44:56 +0100
commit890ffac61bca34172613b6a1d54bbd436859f276 (patch)
treecadb4591f9fba1af2010be2329cde613e60814e9 /lib/api
parent654c4dd9224dc941c073b44730a6461e5d06edfc (diff)
downloadgitlab-ce-890ffac61bca34172613b6a1d54bbd436859f276.tar.gz
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.
Diffstat (limited to 'lib/api')
-rw-r--r--lib/api/groups.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/api/groups.rb b/lib/api/groups.rb
index 64958ff982a..a414b9b326d 100644
--- a/lib/api/groups.rb
+++ b/lib/api/groups.rb
@@ -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