+ <%= form_tag features_path do %>
+
+
+ <% end %>
+
+
<% content_for :onready do %>
$("select").chosen({no_results_text: "No groups matched"});
$("input.users").chosen();
diff --git a/lib/rollout_ui/engine/config/routes.rb b/lib/rollout_ui/engine/config/routes.rb
index 121c161..596d6bf 100644
--- a/lib/rollout_ui/engine/config/routes.rb
+++ b/lib/rollout_ui/engine/config/routes.rb
@@ -1,5 +1,5 @@
RolloutUi::Engine.routes.draw do
- resources :features, :only => [:index, :update]
+ resources :features, :only => [:index, :create, :update, :destroy]
root :to => "features#index"
end
diff --git a/lib/rollout_ui/wrapper.rb b/lib/rollout_ui/wrapper.rb
index ca11666..24aa324 100644
--- a/lib/rollout_ui/wrapper.rb
+++ b/lib/rollout_ui/wrapper.rb
@@ -17,6 +17,10 @@ def add_feature(feature)
redis.sadd(:features, feature)
end
+ def remove_feature(feature)
+ redis.srem(:features, feature)
+ end
+
def features
features = redis.smembers(:features)
features ? features.sort : []
diff --git a/spec/lib/rollout_ui/wrapper_spec.rb b/spec/lib/rollout_ui/wrapper_spec.rb
index d0f332e..9c5a505 100644
--- a/spec/lib/rollout_ui/wrapper_spec.rb
+++ b/spec/lib/rollout_ui/wrapper_spec.rb
@@ -69,4 +69,14 @@
@rollout_ui.features.should == ["featureA"]
end
end
+
+ describe "#remove_feature" do
+ it "removes a feature from the list of features" do
+ @rollout_ui.add_feature(:feature)
+
+ @rollout_ui.remove_feature(:feature)
+
+ @rollout_ui.features.should == []
+ end
+ end
end
diff --git a/spec/requests/engine/engine_spec.rb b/spec/requests/engine/engine_spec.rb
index 869fabd..ff3b6e0 100644
--- a/spec/requests/engine/engine_spec.rb
+++ b/spec/requests/engine/engine_spec.rb
@@ -14,6 +14,18 @@
page.should have_content("featureA")
end
+ describe "remove button" do
+ it "removes the feature" do
+ visit "/rollout"
+
+ within("#featureA .feature-header") do
+ click_button "remove"
+ end
+
+ $rollout.active?(:featureA, user).should be_false
+ end
+ end
+
describe "percentage" do
it "allows changing of the percentage" do
visit "/rollout"
@@ -104,6 +116,19 @@
page.body.should =~ Regexp.new("#{elements.join('.*')}.*", Regexp::MULTILINE)
end
end
+
+ describe "adding a feature" do
+ it "displays the added feature in the UI" do
+ visit "/rollout"
+
+ within(".add-feature") do
+ fill_in "name", with: "featureB"
+ click_button "Add Feature"
+ end
+
+ page.should have_content("featureB")
+ end
+ end
end
end