Skip to content

Commit

Permalink
Remove deprecated Feature class implementation
Browse files Browse the repository at this point in the history
This became dead code now.
  • Loading branch information
sauloperez committed Feb 3, 2021
1 parent 1d75cdc commit fdabd5b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 42 deletions.
25 changes: 3 additions & 22 deletions lib/open_food_network/feature_toggle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,9 @@ def self.enabled?(feature_name, user = nil)
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
Expand Down Expand Up @@ -70,27 +65,13 @@ def true?(value)
end
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
class Feature
def initialize(block)
@block = block
end
Expand Down
20 changes: 0 additions & 20 deletions spec/lib/open_food_network/feature_toggle_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,6 @@ def stub_foo(value)
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' }
Expand Down

0 comments on commit fdabd5b

Please sign in to comment.