From e663725961de66ac838d0a5a85978656938e74f4 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Fri, 16 Dec 2016 12:20:42 +0100 Subject: Store mattermost_url in settings --- spec/lib/mattermost/session_spec.rb | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'spec/lib/mattermost') diff --git a/spec/lib/mattermost/session_spec.rb b/spec/lib/mattermost/session_spec.rb index 69d677930bc..3c2eddbd221 100644 --- a/spec/lib/mattermost/session_spec.rb +++ b/spec/lib/mattermost/session_spec.rb @@ -6,7 +6,7 @@ describe Mattermost::Session, type: :request do let(:gitlab_url) { "http://gitlab.com" } let(:mattermost_url) { "http://mattermost.com" } - subject { described_class.new(mattermost_url, user) } + subject { described_class.new(user) } # Needed for doorkeeper to function it { is_expected.to respond_to(:current_resource_owner) } @@ -14,6 +14,10 @@ describe Mattermost::Session, type: :request do it { is_expected.to respond_to(:authorization) } it { is_expected.to respond_to(:strategy) } + before do + described_class.base_uri(mattermost_url) + end + describe '#with session' do let(:location) { 'http://location.tld' } let!(:stub) do @@ -72,18 +76,22 @@ describe Mattermost::Session, type: :request do end WebMock.stub_request(:post, "#{mattermost_url}/api/v3/users/logout"). - to_return(headers: { Cookie: 'MMAUTHTOKEN=thisworksnow' }, status: 200) + to_return(headers: { Authorization: 'token thisworksnow' }, status: 200) end it 'can setup a session' do - subject.with_session { 1 + 1 } + subject.with_session do |session| + end + expect(subject.token).not_to be_nil end it 'returns the value of the block' do - value = subject.with_session { 1 + 1 } + result = subject.with_session do |session| + "value" + end - expect(value).to be(2) + expect(result).to eq("value") end end end -- cgit v1.2.3