diff options
author | Z.J. van de Weg <git@zjvandeweg.nl> | 2017-02-24 13:25:42 +0100 |
---|---|---|
committer | Z.J. van de Weg <git@zjvandeweg.nl> | 2017-02-24 13:25:42 +0100 |
commit | 9f0e23d6093d67d368485e2ac7e4df0059935770 (patch) | |
tree | 1306e799f14360a76336f7622df21f4503c5939d /app/services/groups | |
parent | 4535129e45cc98ab5a1f17f0950a93bd062e3a5a (diff) | |
download | gitlab-ce-9f0e23d6093d67d368485e2ac7e4df0059935770.tar.gz |
Fix tests
Diffstat (limited to 'app/services/groups')
-rw-r--r-- | app/services/groups/base_service.rb | 6 | ||||
-rw-r--r-- | app/services/groups/create_service.rb | 6 | ||||
-rw-r--r-- | app/services/groups/update_service.rb | 17 |
3 files changed, 19 insertions, 10 deletions
diff --git a/app/services/groups/base_service.rb b/app/services/groups/base_service.rb index a8fa098246a..eb2abcd3723 100644 --- a/app/services/groups/base_service.rb +++ b/app/services/groups/base_service.rb @@ -5,5 +5,11 @@ module Groups def initialize(group, user, params = {}) @group, @current_user, @params = group, user, params.dup end + + private + + def create_chat_team? + @chat_team == "true" && Gitlab.config.mattermost.enabled + end end end diff --git a/app/services/groups/create_service.rb b/app/services/groups/create_service.rb index 3028025fc6e..4ed2cb7c8af 100644 --- a/app/services/groups/create_service.rb +++ b/app/services/groups/create_service.rb @@ -32,11 +32,5 @@ module Groups @group.add_owner(current_user) @group end - - private - - def create_chat_team? - @chat_team && Gitlab.config.mattermost.enabled - end end end diff --git a/app/services/groups/update_service.rb b/app/services/groups/update_service.rb index aff42ad598c..e8ad6d41ed4 100644 --- a/app/services/groups/update_service.rb +++ b/app/services/groups/update_service.rb @@ -1,10 +1,7 @@ module Groups class UpdateService < Groups::BaseService def execute - if params.delete(:create_chat_team) == '1' - chat_name = params[:chat_team_name] - options = chat_name ? { name: chat_name } : {} - end + @chat_team = params.delete(:create_chat_team) # check that user is allowed to set specified visibility_level new_visibility = params[:visibility_level] @@ -19,6 +16,12 @@ module Groups group.assign_attributes(params) + if create_chat_team? + Mattermost::CreateTeamService.new(group, current_user).execute + + return group if group.errors.any? + end + begin group.save rescue Gitlab::UpdatePathError => e @@ -27,5 +30,11 @@ module Groups false end end + + private + + def create_chat_team? + super && group.chat_team.nil? + end end end |