2019-07-25 01:21:37 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-06-12 09:32:29 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 05:08:32 -04:00
|
|
|
RSpec.describe Feature::Gitaly do
|
2019-06-12 10:20:01 -04:00
|
|
|
let(:feature_flag) { "mep_mep" }
|
|
|
|
|
2019-06-12 09:32:29 -04:00
|
|
|
describe ".enabled?" do
|
|
|
|
context 'when the gate is closed' do
|
|
|
|
before do
|
2019-06-12 10:20:01 -04:00
|
|
|
stub_feature_flags(gitaly_mep_mep: false)
|
2019-06-12 09:32:29 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns false' do
|
|
|
|
expect(described_class.enabled?(feature_flag)).to be(false)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-06-12 10:20:01 -04:00
|
|
|
context 'when the flag defaults to on' do
|
|
|
|
it 'returns true' do
|
|
|
|
expect(described_class.enabled?(feature_flag)).to be(true)
|
|
|
|
end
|
2019-06-12 09:32:29 -04:00
|
|
|
end
|
2019-06-12 10:20:01 -04:00
|
|
|
end
|
2019-06-12 09:32:29 -04:00
|
|
|
|
2019-06-12 10:20:01 -04:00
|
|
|
describe ".server_feature_flags" do
|
2020-02-12 07:09:01 -05:00
|
|
|
before do
|
2020-05-29 14:08:26 -04:00
|
|
|
stub_feature_flags(gitaly_mep_mep: true, foo: true)
|
2020-02-12 07:09:01 -05:00
|
|
|
end
|
2019-06-12 09:32:29 -04:00
|
|
|
|
2020-02-12 07:09:01 -05:00
|
|
|
subject { described_class.server_feature_flags }
|
2019-06-12 09:32:29 -04:00
|
|
|
|
2020-02-12 07:09:01 -05:00
|
|
|
it { is_expected.to be_a(Hash) }
|
|
|
|
it { is_expected.to eq("gitaly-feature-mep-mep" => "true") }
|
2020-03-31 08:08:09 -04:00
|
|
|
|
|
|
|
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
|
2019-06-12 09:32:29 -04:00
|
|
|
end
|
|
|
|
end
|