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

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/ruby/spec
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2020-02-11 18:31:09 +0300
committerPaul Okstad <pokstad@gitlab.com>2020-02-11 18:31:09 +0300
commit9e453d793eaae751e02e7f17a34c8b9bb61c5695 (patch)
tree0b36169df38e6f2edfac7fe202343c36f251e7a1 /ruby/spec
parentc01cdbf81f575b2319bae3cc7c6dd469432b916e (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.rb45
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