diff options
author | Robert Speicher <rspeicher@gmail.com> | 2020-02-11 18:31:09 +0300 |
---|---|---|
committer | Paul Okstad <pokstad@gitlab.com> | 2020-02-11 18:31:09 +0300 |
commit | 9e453d793eaae751e02e7f17a34c8b9bb61c5695 (patch) | |
tree | 0b36169df38e6f2edfac7fe202343c36f251e7a1 /ruby/spec | |
parent | c01cdbf81f575b2319bae3cc7c6dd469432b916e (diff) |
Pass specific feature flags to the Ruby server
This will pass the value for specific allowed flags to the Ruby server
via metadata.
Diffstat (limited to 'ruby/spec')
-rw-r--r-- | ruby/spec/lib/gitaly_server/feature_flags_spec.rb | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/ruby/spec/lib/gitaly_server/feature_flags_spec.rb b/ruby/spec/lib/gitaly_server/feature_flags_spec.rb new file mode 100644 index 000000000..56a911bcb --- /dev/null +++ b/ruby/spec/lib/gitaly_server/feature_flags_spec.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe GitalyServer::FeatureFlags do + describe '#enabled?' do + let(:metadata) do + { + "#{described_class::HEADER_PREFIX}some-feature" => 'true', + 'gitaly-storage-path' => 'foo', + 'gitaly-repo-path' => 'bar' + } + end + + subject { described_class.new(metadata) } + + it 'returns true for an enabled flag' do + expect(subject.enabled?(:some_feature)).to eq(true) + end + + it 'returns false for an unknown flag' do + expect(subject.enabled?(:missing_feature)).to eq(false) + end + + it 'removes the prefix if provided' do + expect(subject.enabled?(metadata.keys.first)).to eq(true) + end + + it 'translates underscores' do + expect(subject.enabled?('some-feature')).to eq(true) + end + end + + describe '#disabled?' do + it 'is the inverse of `enabled?`' do + instance = described_class.new({}) + + expect(instance).to receive(:enabled?) + .with(:some_feature) + .and_return(false) + + expect(instance.disabled?(:some_feature)).to eq(true) + end + end +end |