summaryrefslogtreecommitdiff
path: root/spec/lib/feature/gitaly_spec.rb
blob: 6654b7627cd7c89121affe1e5398baf62677ce95 (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'

describe Feature::Gitaly do
  let(:feature_flag) { "mep_mep" }

  describe ".enabled?" do
    context 'when the gate is closed' do
      before do
        stub_feature_flags(gitaly_mep_mep: false)
      end

      it 'returns false' do
        expect(described_class.enabled?(feature_flag)).to be(false)
      end
    end

    context 'when the flag defaults to on' do
      it 'returns true' do
        expect(described_class.enabled?(feature_flag)).to be(true)
      end
    end
  end

  describe ".server_feature_flags" do
    before do
      stub_feature_flags(gitaly_mep_mep: true, foo: true)
    end

    subject { described_class.server_feature_flags }

    it { is_expected.to be_a(Hash) }
    it { is_expected.to eq("gitaly-feature-mep-mep" => "true") }

    context 'when table does not exist' do
      before do
        allow(::Gitlab::Database).to receive(:cached_table_exists?).and_return(false)
      end

      it 'returns an empty Hash' do
        expect(subject).to eq({})
      end
    end
  end
end