Skip to content
Snippets Groups Projects
Unverified Commit 06e03f6e authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre
Browse files

Allow feature flag names to be a symbol

parent b60364c0
No related branches found
No related tags found
1 merge request!10495Merge Requests - Assignee
Loading
Loading
@@ -39,7 +39,7 @@ class Feature
# 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
# on the persisted features list.
persisted_names.include?(feature.name)
persisted_names.include?(feature.name.to_s)
end
 
def enabled?(key, thing = nil)
Loading
Loading
Loading
Loading
@@ -39,18 +39,36 @@ describe Feature do
end
 
describe '.persisted?' do
it 'returns true for a persisted feature' do
Feature::FlipperFeature.create!(key: 'foo')
context 'when the feature is persisted' do
it 'returns true when feature name is a string' do
Feature::FlipperFeature.create!(key: 'foo')
feature = double(:feature, name: 'foo')
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')
feature = double(:feature, name: :foo)
 
expect(described_class.persisted?(feature)).to eq(true)
expect(described_class.persisted?(feature)).to eq(true)
end
end
 
it 'returns false for a feature that is not persisted' do
feature = double(:feature, name: 'foo')
context 'when the feature is not persisted' do
it 'returns false when feature name is a string' do
feature = double(:feature, name: 'foo')
expect(described_class.persisted?(feature)).to eq(false)
end
 
expect(described_class.persisted?(feature)).to eq(false)
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
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment