diff options
author | Z.J. van de Weg <git@zjvandeweg.nl> | 2016-12-19 14:14:09 +0100 |
---|---|---|
committer | Z.J. van de Weg <git@zjvandeweg.nl> | 2016-12-19 21:44:15 +0100 |
commit | d21535602b30316646772b1cd74d7069254076df (patch) | |
tree | d5e7533b44d646e8aaee153ce7b0f51e9467faa7 /spec/lib/mattermost | |
parent | 4213bd56dea1d6cdbfa8baed8faa7e3ab86e61ab (diff) | |
download | gitlab-ce-d21535602b30316646772b1cd74d7069254076df.tar.gz |
Minor adjustments API Mattermost
[ci skip]
Diffstat (limited to 'spec/lib/mattermost')
-rw-r--r-- | spec/lib/mattermost/command_spec.rb | 20 | ||||
-rw-r--r-- | spec/lib/mattermost/session_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/mattermost/team_spec.rb | 18 |
3 files changed, 25 insertions, 15 deletions
diff --git a/spec/lib/mattermost/command_spec.rb b/spec/lib/mattermost/command_spec.rb index 7c6457f639d..bc2e47ebbc9 100644 --- a/spec/lib/mattermost/command_spec.rb +++ b/spec/lib/mattermost/command_spec.rb @@ -1,17 +1,25 @@ require 'spec_helper' describe Mattermost::Command do + let(:session) { double("session") } + let(:hash) { { 'token' => 'token' } } + describe '.create' do - let(:new_command) do - JSON.parse(File.read(Rails.root.join('spec/fixtures/', 'mattermost_new_command.json'))) + before do + allow(session).to receive(:post).and_return(hash) + allow(hash).to receive(:parsed_response).and_return(hash) end - it 'gets the teams' do - allow(described_class).to receive(:post_command).and_return(new_command) + context 'with access' do + it 'gets the teams' do + expect(session).to receive(:post) + + described_class.create(session, 'abc', url: 'http://trigger.com') + end + end - token = described_class.create('abc', url: 'http://trigger.url/trigger', icon_url: 'http://myicon.com/icon.png') + context 'on an error' do - expect(token).to eq('pzajm5hfbtni3r49ujpt8betpc') end end end diff --git a/spec/lib/mattermost/session_spec.rb b/spec/lib/mattermost/session_spec.rb index 752ac796b1c..3c2eddbd221 100644 --- a/spec/lib/mattermost/session_spec.rb +++ b/spec/lib/mattermost/session_spec.rb @@ -96,4 +96,4 @@ describe Mattermost::Session, type: :request do end end end -end
\ No newline at end of file +end diff --git a/spec/lib/mattermost/team_spec.rb b/spec/lib/mattermost/team_spec.rb index 0fe6163900d..32a0dbf42ec 100644 --- a/spec/lib/mattermost/team_spec.rb +++ b/spec/lib/mattermost/team_spec.rb @@ -2,20 +2,22 @@ require 'spec_helper' describe Mattermost::Team do describe '.team_admin' do - let(:init_load) do - JSON.parse(File.read(Rails.root.join('spec/fixtures/', 'mattermost_initial_load.json'))) - end + let(:session) { double("session") } + # TODO fix fixture + let(:json) { File.read(Rails.root.join('spec/fixtures/', 'mattermost_initial_load.json')) } + let(:parsed_response) { JSON.parse(json) } before do - allow(described_class).to receive(:initial_load).and_return(init_load) + allow(session).to receive(:get).with('/api/v3/teams/all'). + and_return(json) + allow(json).to receive(:parsed_response).and_return(parsed_response) end - it 'gets the teams' do - expect(described_class.team_admin.count).to be(2) + xit 'gets the teams' do + expect(described_class.all(session).count).to be(2) end - it 'filters on being team admin' do - ids = described_class.team_admin.map { |team| team['id'] } + xit 'filters on being team admin' do expect(ids).to include("w59qt5a817f69jkxdz6xe7y4ir", "my9oujxf5jy1zqdgu9rihd66do") end end |