Add FeatureToggle config to replace ENV['OFW_DEPLOYMENT']

This commit is contained in:
Rohan Mitchell
2013-07-22 12:11:52 +10:00
parent 6ceb8e9ee7
commit 7b1d1f1d42
3 changed files with 37 additions and 0 deletions

1
.gitignore vendored
View File

@@ -28,5 +28,6 @@ public/images
public/spree
config/abr.yml
config/heroku_env.rb
config/initializers/feature_toggle.rb
NERD_tree*
coverage

View File

@@ -0,0 +1,16 @@
module OpenFoodWeb
class FeatureToggle
def self.enabled? feature
features[feature]
end
private
def self.features
{eaterprises: true,
local_organics: false,
enterprises_distributor_info_rich_text: false}
end
end
end

View File

@@ -0,0 +1,20 @@
require 'open_food_web/feature_toggle'
module OpenFoodWeb
describe FeatureToggle do
it "returns true when feature is on" do
FeatureToggle.stub(:features).and_return({foo: true})
FeatureToggle.enabled?(:foo).should be_true
end
it "returns false when feature is off" do
FeatureToggle.stub(:features).and_return({foo: false})
FeatureToggle.enabled?(:foo).should be_false
end
it "returns false when feature is undefined" do
FeatureToggle.stub(:features).and_return({})
FeatureToggle.enabled?(:foo).should be_false
end
end
end