diff --git a/app/controllers/flip/strategies_controller.rb b/app/controllers/flip/strategies_controller.rb index 11a1920..f59d599 100644 --- a/app/controllers/flip/strategies_controller.rb +++ b/app/controllers/flip/strategies_controller.rb @@ -5,12 +5,12 @@ class StrategiesController < ApplicationController def update strategy.switch! feature_key, turn_on? - redirect_to features_url + redirect_to flip.features_url end def destroy strategy.delete! feature_key - redirect_to features_url + redirect_to flip.features_url end private diff --git a/config/routes.rb b/config/routes.rb index b4ae720..3f5a85d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,14 +1,6 @@ Flip::Engine.routes.draw do - - scope module: "flip" do - - resources :features, path: "", only: [ :index ] do - - resources :strategies, - only: [ :update, :destroy ] - - end - + resources :features, path: "", only: [ :index ] do + resources :strategies, + only: [ :update, :destroy ] end - end diff --git a/flip.gemspec b/flip.gemspec index 37f6ca5..7706c44 100644 --- a/flip.gemspec +++ b/flip.gemspec @@ -24,4 +24,6 @@ Gem::Specification.new do |s| s.add_development_dependency("rspec", "~> 2.5") s.add_development_dependency("rspec-its") s.add_development_dependency("rake") + s.add_development_dependency("rack") + s.add_development_dependency("actionpack", ">= 3.0", "< 5") end diff --git a/lib/flip/cookie_strategy.rb b/lib/flip/cookie_strategy.rb index e02cf7e..08b4245 100644 --- a/lib/flip/cookie_strategy.rb +++ b/lib/flip/cookie_strategy.rb @@ -28,7 +28,7 @@ def switch! key, on end def delete! key - cookies.delete cookie_name(key) + cookies.delete cookie_name(key), domain: :all end def self.cookies= cookies diff --git a/lib/flip/engine.rb b/lib/flip/engine.rb index 655d165..03b7cbb 100644 --- a/lib/flip/engine.rb +++ b/lib/flip/engine.rb @@ -1,9 +1,13 @@ module Flip class Engine < ::Rails::Engine + isolate_namespace Flip initializer "flip.blarg" do ActionController::Base.send(:include, Flip::CookieStrategy::Loader) end + initializer "flip.assets.precompile" do |app| + app.config.assets.precompile += %w(flip.css) + end end end diff --git a/spec/cookie_strategy_spec.rb b/spec/cookie_strategy_spec.rb index 929548c..4b32f8c 100644 --- a/spec/cookie_strategy_spec.rb +++ b/spec/cookie_strategy_spec.rb @@ -1,18 +1,28 @@ require "spec_helper" +require "action_dispatch" +require "rack" class ControllerWithoutCookieStrategy; end class ControllerWithCookieStrategy def self.before_filter(_); end def self.after_filter(_); end - def cookies; []; end + def cookies; cookie_jar; end include Flip::CookieStrategy::Loader end +def cookie_jar + env = Rack::MockRequest.env_for("/example") + request = ActionDispatch::TestRequest.new(env) + ActionDispatch::Cookies::CookieJar.build(request) +end + describe Flip::CookieStrategy do let(:cookies) do - { strategy.cookie_name(:one) => "true", - strategy.cookie_name(:two) => "false" } + cookie_jar.tap do |jar| + jar[strategy.cookie_name(:one)] = "true" + jar[strategy.cookie_name(:two)] = "false" + end end let(:strategy) do Flip::CookieStrategy.new.tap do |s|