Welcome to mirror list, hosted at ThFree Co, Russian Federation.

mattermost_spec.rb « mattermost « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7c99b4df9f3dbd6370d6833c8e80e8b960276f0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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