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

omniauth_spec.rb « initializers « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 928eac8c53388638baf4f462f36333b0a2ec8342 (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
43
44
45
46
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'OmniAuth initializer for GitLab' do
  let(:load_omniauth_initializer) do
    load Rails.root.join('config/initializers/omniauth.rb')
  end

  describe '#full_host' do
    subject { OmniAuth.config.full_host }

    let(:base_url) { 'http://localhost/test' }

    before do
      allow(Settings).to receive(:gitlab).and_return({ 'base_url' => base_url })
      allow(Gitlab::OmniauthInitializer).to receive(:full_host).and_return('proc')
    end

    context 'with feature flags not available' do
      before do
        expect(Feature).to receive(:feature_flags_available?).and_return(false)
        load_omniauth_initializer
      end

      it { is_expected.to eq(base_url) }
    end

    context 'with the omniauth_initializer_fullhost_proc FF disabled' do
      before do
        stub_feature_flags(omniauth_initializer_fullhost_proc: false)
        load_omniauth_initializer
      end

      it { is_expected.to eq(base_url) }
    end

    context 'with the omniauth_initializer_fullhost_proc FF disabled' do
      before do
        load_omniauth_initializer
      end

      it { is_expected.to eq('proc') }
    end
  end
end