diff options
author | Z.J. van de Weg <git@zjvandeweg.nl> | 2016-12-16 15:45:56 +0100 |
---|---|---|
committer | Z.J. van de Weg <git@zjvandeweg.nl> | 2016-12-16 15:51:43 +0100 |
commit | 7363a7d3b5804493f86531bebb1610afb91b5293 (patch) | |
tree | 2b02129b40b30995d7f938b7e248c4e58d7e8ea1 /lib/mattermost | |
parent | 475a4dc34dd775147dafebcf1b4d648bf2b9aeec (diff) | |
download | gitlab-ce-7363a7d3b5804493f86531bebb1610afb91b5293.tar.gz |
Add tests for auto configure slash commands
Diffstat (limited to 'lib/mattermost')
-rw-r--r-- | lib/mattermost/command.rb | 8 | ||||
-rw-r--r-- | lib/mattermost/team.rb | 14 |
2 files changed, 15 insertions, 7 deletions
diff --git a/lib/mattermost/command.rb b/lib/mattermost/command.rb index 108a2a47a4b..7d4710bb94d 100644 --- a/lib/mattermost/command.rb +++ b/lib/mattermost/command.rb @@ -14,9 +14,13 @@ module Mattermost icon_url: icon_url } - response = post( "/teams/#{team_id}/commands/create", body: command.to_json) + post_command(command)['token'] + end + + private - response.parsed_response['token'] + def post_command(command) + post( "/teams/#{team_id}/commands/create", body: command.to_json).parsed_response end end end 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 |