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

bullet_spec.rb « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c575c656bb4d5bdb46e3af3fbf3a684ab769180a (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
47
48
49
50
51
52
53
54
55
56
57
58
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Bullet do
  context 'with bullet installed' do
    before do
      stub_env('ENABLE_BULLET', nil)
      stub_const('::Bullet', double)
    end

    describe '#enabled?' do
      context 'with env enabled' do
        before do
          stub_env('ENABLE_BULLET', true)
          allow(Gitlab.config.bullet).to receive(:enabled).and_return(false)
        end

        it 'is enabled' do
          expect(described_class.enabled?).to be(true)
        end
      end

      context 'with env disabled' do
        before do
          stub_env('ENABLE_BULLET', false)
          allow(Gitlab.config.bullet).to receive(:enabled).and_return(true)
        end

        it 'is not enabled' do
          expect(described_class.enabled?).to be(false)
        end
      end
    end

    describe '#configure_bullet?' do
      context 'with config enabled' do
        before do
          allow(Gitlab.config.bullet).to receive(:enabled).and_return(true)
        end

        it 'is configurable' do
          expect(described_class.configure_bullet?).to be(true)
        end
      end

      context 'with config disabled' do
        before do
          allow(Gitlab.config.bullet).to receive(:enabled).and_return(false)
        end

        it 'is not configurable' do
          expect(described_class.configure_bullet?).to be(false)
        end
      end
    end
  end
end