Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZ.J. van de Weg <git@zjvandeweg.nl>2017-02-03 13:29:56 +0300
committerZ.J. van de Weg <git@zjvandeweg.nl>2017-02-16 11:19:02 +0300
commit1a0e54b32d43e2a3de88c20037bd167b1f8563d6 (patch)
tree21b9a0fe8cc36425b105c5065ec951ea390a177e /lib/mattermost
parent297dc70158f905fef4557d1ee6510bcf459a08a9 (diff)
Add tests for Mattermost team creation
Diffstat (limited to 'lib/mattermost')
-rw-r--r--lib/mattermost/client.rb2
-rw-r--r--lib/mattermost/team.rb18
2 files changed, 17 insertions, 3 deletions
diff --git a/lib/mattermost/client.rb b/lib/mattermost/client.rb
index e55c0d6ac49..29b10e2afce 100644
--- a/lib/mattermost/client.rb
+++ b/lib/mattermost/client.rb
@@ -26,7 +26,7 @@ module Mattermost
def session_get(path, options = {})
with_session do |session|
- get(session, path, options)
+ get(session, path, options)
end
end
diff --git a/lib/mattermost/team.rb b/lib/mattermost/team.rb
index 9e80f7f8571..d5648f7167f 100644
--- a/lib/mattermost/team.rb
+++ b/lib/mattermost/team.rb
@@ -5,8 +5,22 @@ module Mattermost
session_get('/api/v3/teams/all')
end
- def create(params)
- session_post('/api/v3/teams/create', body: params.to_json)
+ # Creates a team on the linked Mattermost instance, the team admin will be the
+ # `current_user` passed to the Mattermost::Client instance
+ def create(group, params)
+ session_post('/api/v3/teams/create', body: new_team_params(group, params).to_json)
+ end
+
+ private
+
+ MATTERMOST_TEAM_LENGTH_MAX = 59
+
+ def new_team_params(group, options)
+ {
+ name: group.path[0..MATTERMOST_TEAM_LENGTH_MAX],
+ display_name: group.name[0..MATTERMOST_TEAM_LENGTH_MAX],
+ type: group.public? ? 'O' : 'I' # Open vs Invite-only
+ }.merge(options)
end
end
end