summaryrefslogtreecommitdiff
path: root/lib/mattermost/team.rb
diff options
context:
space:
mode:
authorZ.J. van de Weg <git@zjvandeweg.nl>2016-12-16 15:45:56 +0100
committerZ.J. van de Weg <git@zjvandeweg.nl>2016-12-16 15:51:43 +0100
commit7363a7d3b5804493f86531bebb1610afb91b5293 (patch)
tree2b02129b40b30995d7f938b7e248c4e58d7e8ea1 /lib/mattermost/team.rb
parent475a4dc34dd775147dafebcf1b4d648bf2b9aeec (diff)
downloadgitlab-ce-7363a7d3b5804493f86531bebb1610afb91b5293.tar.gz
Add tests for auto configure slash commands
Diffstat (limited to 'lib/mattermost/team.rb')
-rw-r--r--lib/mattermost/team.rb14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/mattermost/team.rb b/lib/mattermost/team.rb
index 54d029cb022..714748aea3c 100644
--- a/lib/mattermost/team.rb
+++ b/lib/mattermost/team.rb
@@ -1,17 +1,21 @@
module Mattermost
class Team < Session
def self.team_admin
- body = get('/users/initial_load').parsed_response
+ return [] unless initial_load['team_members']
- return [] unless body['team_members']
-
- team_ids = body['team_members'].map do |team|
+ team_ids = initial_load['team_members'].map do |team|
team['team_id'] if team['roles'].split.include?('team_admin')
end.compact
- body['teams'].select do |team|
+ initial_load['teams'].select do |team|
team_ids.include?(team['id'])
end
end
+
+ private
+
+ def initial_load
+ @initial_load ||= get('/users/initial_load').parsed_response
+ end
end
end