Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ Put this somewhere before the `URLMap` in your `config.ru`:
username == '<some username>' && password == '<some password>'
end

Configuration
-------------

By default, RolloutUI will attempt to take notice of new features that are not
yet enabled. This behavior requires the use of redis as a backend to rollout. If
you are using a different backend, you should disable this feature:

`RolloutUi.track_features = false`

Resources
---------

Expand Down
10 changes: 10 additions & 0 deletions lib/rollout_ui.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,14 @@ def self.wrap(rollout)
def self.rollout
@@rollout
end

def self.track_features=(value)
@@track_features = value
end

def self.track_features
@@track_features
end
self.track_features = true

end
2 changes: 1 addition & 1 deletion lib/rollout_ui/monkey_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class Rollout
alias_method :original_active?, :active?

def active?(feature, user=nil)
RolloutUi::Wrapper.new(self).add_feature(feature)
RolloutUi::Wrapper.new(self).add_feature(feature) if RolloutUi.track_features
original_active?(feature, user)
end
end
7 changes: 6 additions & 1 deletion lib/rollout_ui/wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ def add_feature(feature)
end

def features
features = redis.smembers(:features)
features =
if RolloutUi.track_features
redis.smembers(:features)
else
rollout.features
end
features ? features.sort : []
end

Expand Down
10 changes: 10 additions & 0 deletions spec/lib/rollout_ui/wrapper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@

@rollout_ui.features.should == %w(anotherFeature featureA featureB zFeature)
end

context "with feature tracking disabled" do
before(:all) { RolloutUi.track_features = false }
after(:all) { RolloutUi.track_features = true }

it "should not notice new features" do
$rollout.active?(:featureA)
@rollout_ui.features.should == []
end
end
end

describe "#add_feature" do
Expand Down