diff options
author | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2019-06-12 15:32:29 +0200 |
---|---|---|
committer | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2019-06-18 13:18:18 +0200 |
commit | 968674e41798c437b9ebf4a9731fe2f2a4f07024 (patch) | |
tree | 0fdc959be0443bff849cf704ed762902ff265ef3 /spec/lib | |
parent | 28f7846c4723457c6d53808215796515396eaa7d (diff) | |
download | gitlab-ce-968674e41798c437b9ebf4a9731fe2f2a4f07024.tar.gz |
Move Gitaly feature flag logic to Feature::Gitaly
The GitalyClient held a lot of logic which was all very tightly coupled.
In this instance the feature logic was extracted to make it do just a
little less and create a bit more focus in the GitalyClient's
responsibilies.
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/feature/gitaly_spec.rb | 32 | ||||
-rw-r--r-- | spec/lib/gitlab/gitaly_client_spec.rb | 14 |
2 files changed, 32 insertions, 14 deletions
diff --git a/spec/lib/feature/gitaly_spec.rb b/spec/lib/feature/gitaly_spec.rb new file mode 100644 index 00000000000..12923e4ec41 --- /dev/null +++ b/spec/lib/feature/gitaly_spec.rb @@ -0,0 +1,32 @@ +require 'spec_helper' + +describe Feature::Gitaly do + let(:feature_flag) { "mepmep" } + + describe ".enabled?" do + context 'when the gate is closed' do + before do + allow(Feature).to receive(:enabled?).with("gitaly_mepmep").and_return(false) + end + + it 'returns false' do + expect(described_class.enabled?(feature_flag)).to be(false) + end + end + end + + describe ".server_feature_flags" do + before do + stub_const("#{described_class}::SERVER_FEATURE_FLAGS", [feature_flag]) + allow(Feature).to receive(:enabled?).with("gitaly_mepmep").and_return(false) + end + + subject { described_class.server_feature_flags } + + it { is_expected.to be_a(Hash) } + + context 'when one flag is disabled' do + it { is_expected.to eq("gitaly-feature-mepmep" => "false") } + end + end +end diff --git a/spec/lib/gitlab/gitaly_client_spec.rb b/spec/lib/gitlab/gitaly_client_spec.rb index da1eb0c2618..eed233f1f3e 100644 --- a/spec/lib/gitlab/gitaly_client_spec.rb +++ b/spec/lib/gitlab/gitaly_client_spec.rb @@ -330,20 +330,6 @@ describe Gitlab::GitalyClient do end end - describe 'feature_enabled?' do - let(:feature_name) { 'my_feature' } - let(:real_feature_name) { "gitaly_#{feature_name}" } - - before do - allow(Feature).to receive(:enabled?).and_return(false) - end - - it 'returns false' do - expect(Feature).to receive(:enabled?).with(real_feature_name) - expect(described_class.feature_enabled?(feature_name)).to be(false) - end - end - describe 'timeouts' do context 'with default values' do before do |