diff options
author | Z.J. van de Weg <git@zjvandeweg.nl> | 2016-12-12 09:31:48 +0100 |
---|---|---|
committer | Z.J. van de Weg <git@zjvandeweg.nl> | 2016-12-17 10:31:14 +0100 |
commit | f11caaf4692afdde0a2c458b3682aef3f9658b6a (patch) | |
tree | 5c0c6e010ef41c88e5ecc422ad8009ebdeb51d9b /spec/lib/mattermost | |
parent | 0a6450094eb13702f6f6f03e468db4fc8f023315 (diff) | |
download | gitlab-ce-f11caaf4692afdde0a2c458b3682aef3f9658b6a.tar.gz |
Setup mattermost session
Diffstat (limited to 'spec/lib/mattermost')
-rw-r--r-- | spec/lib/mattermost/mattermost_spec.rb | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/lib/mattermost/mattermost_spec.rb b/spec/lib/mattermost/mattermost_spec.rb new file mode 100644 index 00000000000..7c99b4df9f3 --- /dev/null +++ b/spec/lib/mattermost/mattermost_spec.rb @@ -0,0 +1,42 @@ +require 'spec_helper' + +describe Mattermost::Mattermost do + let(:user) { create(:user) } + + subject { described_class.new('http://localhost:8065', user) } + + # Needed for doorman to function + it { is_expected.to respond_to(:current_resource_owner) } + it { is_expected.to respond_to(:request) } + it { is_expected.to respond_to(:authorization) } + it { is_expected.to respond_to(:strategy) } + + describe '#with session' do + let!(:stub) do + WebMock.stub_request(:get, 'http://localhost:8065/api/v3/oauth/gitlab/login'). + to_return(headers: { 'location' => 'http://mylocation.com' }, status: 307) + end + + context 'without oauth uri' do + it 'makes a request to the oauth uri' do + expect { subject.with_session }.to raise_error(Mattermost::NoSessionError) + end + + context 'with oauth_uri' do + let!(:doorkeeper) do + Doorkeeper::Application.create(name: "GitLab Mattermost", + redirect_uri: "http://localhost:8065/signup/gitlab/complete\nhttp://localhost:8065/login/gitlab/complete", + scopes: "") + end + + context 'without token_uri' do + it 'can not create a session' do + expect do + subject.with_session + end.to raise_error(Mattermost::NoSessionError) + end + end + end + end + end +end |