Merge branch 'da-feature-flags' into 'master'
Allow feature flag names to be a symbol See merge request gitlab-org/gitlab-ce!20728
This commit is contained in:
commit
cc540bb2a2
|
@ -39,7 +39,7 @@ class Feature
|
||||||
# Flipper creates on-memory features when asked for a not-yet-created one.
|
# Flipper creates on-memory features when asked for a not-yet-created one.
|
||||||
# If we want to check if a feature has been actually set, we look for it
|
# If we want to check if a feature has been actually set, we look for it
|
||||||
# on the persisted features list.
|
# on the persisted features list.
|
||||||
persisted_names.include?(feature.name)
|
persisted_names.include?(feature.name.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
def enabled?(key, thing = nil)
|
def enabled?(key, thing = nil)
|
||||||
|
|
|
@ -39,18 +39,36 @@ describe Feature do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.persisted?' do
|
describe '.persisted?' do
|
||||||
it 'returns true for a persisted feature' do
|
context 'when the feature is persisted' do
|
||||||
Feature::FlipperFeature.create!(key: 'foo')
|
it 'returns true when feature name is a string' do
|
||||||
|
Feature::FlipperFeature.create!(key: 'foo')
|
||||||
|
|
||||||
feature = double(:feature, name: 'foo')
|
feature = double(:feature, name: 'foo')
|
||||||
|
|
||||||
expect(described_class.persisted?(feature)).to eq(true)
|
expect(described_class.persisted?(feature)).to eq(true)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns true when feature name is a symbol' do
|
||||||
|
Feature::FlipperFeature.create!(key: 'foo')
|
||||||
|
|
||||||
|
feature = double(:feature, name: :foo)
|
||||||
|
|
||||||
|
expect(described_class.persisted?(feature)).to eq(true)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns false for a feature that is not persisted' do
|
context 'when the feature is not persisted' do
|
||||||
feature = double(:feature, name: 'foo')
|
it 'returns false when feature name is a string' do
|
||||||
|
feature = double(:feature, name: 'foo')
|
||||||
|
|
||||||
expect(described_class.persisted?(feature)).to eq(false)
|
expect(described_class.persisted?(feature)).to eq(false)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns false when feature name is a symbol' do
|
||||||
|
feature = double(:feature, name: :bar)
|
||||||
|
|
||||||
|
expect(described_class.persisted?(feature)).to eq(false)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue