spec/flipper/ui/actions/feature_spec.rb in flipper-ui-0.9.1 vs spec/flipper/ui/actions/feature_spec.rb in flipper-ui-0.9.2
- old
+ new
@@ -1,14 +1,29 @@
require 'helper'
RSpec.describe Flipper::UI::Actions::Feature do
+ let(:token) {
+ if Rack::Protection::AuthenticityToken.respond_to?(:random_token)
+ Rack::Protection::AuthenticityToken.random_token
+ else
+ "a"
+ end
+ }
+ let(:session) {
+ if Rack::Protection::AuthenticityToken.respond_to?(:random_token)
+ {:csrf => token}
+ else
+ {"_csrf_token" => token}
+ end
+ }
+
describe "DELETE /features/:feature" do
before do
flipper.enable :search
delete "/features/search",
- {"authenticity_token" => "a"},
- "rack.session" => {"_csrf_token" => "a"}
+ {"authenticity_token" => token},
+ "rack.session" => session
end
it "removes feature" do
expect(flipper.features.map(&:key)).not_to include("search")
end
@@ -21,11 +36,11 @@
describe "POST /features/:feature with _method=DELETE" do
before do
flipper.enable :search
post "/features/search",
- {"_method" => "DELETE", "authenticity_token" => "a"},
- "rack.session" => {"_csrf_token" => "a"}
+ {"_method" => "DELETE", "authenticity_token" => token},
+ "rack.session" => session
end
it "removes feature" do
expect(flipper.features.map(&:key)).not_to include("search")
end