mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-09 23:06:06 +00:00
Remove deprecated Feature class implementation
This became dead code now.
This commit is contained in:
@@ -30,14 +30,9 @@ module OpenFoodNetwork
|
||||
new.enabled?(feature_name, user)
|
||||
end
|
||||
|
||||
def self.enable(feature_name, user_emails = nil, &block)
|
||||
def self.enable(feature_name, &block)
|
||||
Thread.current[:features] ||= {}
|
||||
|
||||
if user_emails.nil?
|
||||
Thread.current[:features][feature_name] = BlockFeature.new(block)
|
||||
else
|
||||
Thread.current[:features][feature_name] = Feature.new(user_emails)
|
||||
end
|
||||
Thread.current[:features][feature_name] = Feature.new(block)
|
||||
end
|
||||
|
||||
def initialize
|
||||
@@ -71,26 +66,6 @@ module OpenFoodNetwork
|
||||
end
|
||||
|
||||
class Feature
|
||||
def initialize(users = [])
|
||||
@users = users
|
||||
end
|
||||
|
||||
def enabled?(user)
|
||||
users.include?(user.email)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
attr_reader :users
|
||||
end
|
||||
|
||||
class NullFeature
|
||||
def enabled?(_user)
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
class BlockFeature
|
||||
def initialize(block)
|
||||
@block = block
|
||||
end
|
||||
@@ -103,4 +78,10 @@ module OpenFoodNetwork
|
||||
|
||||
attr_reader :block
|
||||
end
|
||||
|
||||
class NullFeature
|
||||
def enabled?(_user)
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -32,26 +32,6 @@ module OpenFoodNetwork
|
||||
context 'when specifying users' do
|
||||
let(:user) { build(:user) }
|
||||
|
||||
context 'and the feature is enabled for them' do
|
||||
before { FeatureToggle.enable(:foo, [user.email]) }
|
||||
|
||||
it 'returns true' do
|
||||
expect(FeatureToggle.enabled?(:foo, user)).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
context 'and the feature is disabled for them' do
|
||||
before { FeatureToggle.enable(:foo, []) }
|
||||
|
||||
it 'returns false' do
|
||||
expect(FeatureToggle.enabled?(:foo, user)).to eq(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when passing in a block' do
|
||||
let(:user) { build(:user) }
|
||||
|
||||
context 'and the block does not specify arguments' do
|
||||
before do
|
||||
FeatureToggle.enable(:foo) { 'return value' }
|
||||
|
||||
Reference in New Issue
Block a user