summaryrefslogtreecommitdiff
path: root/spec/lib/mattermost
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 /spec/lib/mattermost
parent475a4dc34dd775147dafebcf1b4d648bf2b9aeec (diff)
downloadgitlab-ce-7363a7d3b5804493f86531bebb1610afb91b5293.tar.gz
Add tests for auto configure slash commands
Diffstat (limited to 'spec/lib/mattermost')
-rw-r--r--spec/lib/mattermost/command_spec.rb17
-rw-r--r--spec/lib/mattermost/team_spec.rb19
2 files changed, 28 insertions, 8 deletions
diff --git a/spec/lib/mattermost/command_spec.rb b/spec/lib/mattermost/command_spec.rb
new file mode 100644
index 00000000000..7c6457f639d
--- /dev/null
+++ b/spec/lib/mattermost/command_spec.rb
@@ -0,0 +1,17 @@
+require 'spec_helper'
+
+describe Mattermost::Command do
+ describe '.create' do
+ let(:new_command) do
+ JSON.parse(File.read(Rails.root.join('spec/fixtures/', 'mattermost_new_command.json')))
+ end
+
+ it 'gets the teams' do
+ allow(described_class).to receive(:post_command).and_return(new_command)
+
+ token = described_class.create('abc', url: 'http://trigger.url/trigger', icon_url: 'http://myicon.com/icon.png')
+
+ expect(token).to eq('pzajm5hfbtni3r49ujpt8betpc')
+ end
+ end
+end
diff --git a/spec/lib/mattermost/team_spec.rb b/spec/lib/mattermost/team_spec.rb
index a3b0831659f..0fe6163900d 100644
--- a/spec/lib/mattermost/team_spec.rb
+++ b/spec/lib/mattermost/team_spec.rb
@@ -1,19 +1,22 @@
require 'spec_helper'
describe Mattermost::Team do
- let(:session) { Mattermost::Session.new('http://localhost:8065/', nil) }
+ describe '.team_admin' do
+ let(:init_load) do
+ JSON.parse(File.read(Rails.root.join('spec/fixtures/', 'mattermost_initial_load.json')))
+ end
- describe '.all' do
- let(:result) { {id: 'abc', display_name: 'team'} }
before do
- WebMock.stub_request(:get, 'http://localhost:8065/api/v3/teams/all').
- and_return({ abc: result }.to_json)
+ allow(described_class).to receive(:initial_load).and_return(init_load)
end
- xit 'gets the teams' do
- allow(session).to receive(:with_session) { yield }
+ it 'gets the teams' do
+ expect(described_class.team_admin.count).to be(2)
+ end
- expect(described_class.all).to eq(result)
+ it 'filters on being team admin' do
+ ids = described_class.team_admin.map { |team| team['id'] }
+ expect(ids).to include("w59qt5a817f69jkxdz6xe7y4ir", "my9oujxf5jy1zqdgu9rihd66do")
end
end
end