diff options
author | Z.J. van de Weg <git@zjvandeweg.nl> | 2016-12-20 00:07:19 +0300 |
---|---|---|
committer | Z.J. van de Weg <git@zjvandeweg.nl> | 2016-12-20 00:07:19 +0300 |
commit | 5d197230067edd8255b422b5970eb34bda061048 (patch) | |
tree | 151da05f06ae090d55fb14f91144d99c52cb27b6 /spec/lib/mattermost | |
parent | d21535602b30316646772b1cd74d7069254076df (diff) | |
parent | 05d04d04980db9d64c7679999200e03a6820bc31 (diff) |
Merge remote-tracking branch 'origin/zj-mattermost-slash-config' into zj-mattermost-slash-config
Diffstat (limited to 'spec/lib/mattermost')
-rw-r--r-- | spec/lib/mattermost/command_spec.rb | 12 | ||||
-rw-r--r-- | spec/lib/mattermost/team_spec.rb | 33 |
2 files changed, 28 insertions, 17 deletions
diff --git a/spec/lib/mattermost/command_spec.rb b/spec/lib/mattermost/command_spec.rb index bc2e47ebbc9..f38bb273e7d 100644 --- a/spec/lib/mattermost/command_spec.rb +++ b/spec/lib/mattermost/command_spec.rb @@ -10,16 +10,10 @@ describe Mattermost::Command do allow(hash).to receive(:parsed_response).and_return(hash) end - 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 - - context 'on an error' do + it 'gets the teams' do + expect(session).to receive(:post) + described_class.create(session, 'abc', url: 'http://trigger.com') end end end diff --git a/spec/lib/mattermost/team_spec.rb b/spec/lib/mattermost/team_spec.rb index 32a0dbf42ec..d4fe63fcd8b 100644 --- a/spec/lib/mattermost/team_spec.rb +++ b/spec/lib/mattermost/team_spec.rb @@ -3,22 +3,39 @@ require 'spec_helper' describe Mattermost::Team do describe '.team_admin' do 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) } + + let(:response) do + [{ + "id"=>"xiyro8huptfhdndadpz8r3wnbo", + "create_at"=>1482174222155, + "update_at"=>1482174222155, + "delete_at"=>0, + "display_name"=>"chatops", + "name"=>"chatops", + "email"=>"admin@example.com", + "type"=>"O", + "company_name"=>"", + "allowed_domains"=>"", + "invite_id"=>"o4utakb9jtb7imctdfzbf9r5ro", + "allow_open_invite"=>false}] + end + + let(:json) { nil } before do allow(session).to receive(:get).with('/api/v3/teams/all'). and_return(json) - allow(json).to receive(:parsed_response).and_return(parsed_response) + allow(json).to receive(:parsed_response).and_return(response) end - xit 'gets the teams' do - expect(described_class.all(session).count).to be(2) + it 'gets the teams' do + expect(described_class.all(session).count).to be(1) end - xit 'filters on being team admin' do - expect(ids).to include("w59qt5a817f69jkxdz6xe7y4ir", "my9oujxf5jy1zqdgu9rihd66do") + it 'filters on being team admin' do + ids = described_class.all(session).map { |team| team['id'] } + + expect(ids).to include("xiyro8huptfhdndadpz8r3wnbo") end end end |