spec/flipper/ui_spec.rb in flipper-ui-0.9.1 vs spec/flipper/ui_spec.rb in flipper-ui-0.9.2

- old
+ new

@@ -1,8 +1,23 @@ require 'helper' RSpec.describe Flipper::UI 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 "Initializing middleware with flipper instance" do let(:app) { build_app(flipper) } it "works" do flipper.enable :some_great_feature @@ -34,11 +49,11 @@ end # See https://github.com/jnunemaker/flipper/issues/80 it "can route features with names that match static directories" do post "features/refactor-images/actors", - {"value" => "User:6", "operation" => "enable", "authenticity_token" => "a"}, - "rack.session" => {"_csrf_token" => "a"} + {"value" => "User:6", "operation" => "enable", "authenticity_token" => token}, + "rack.session" => session expect(last_response.status).to be(302) expect(last_response.headers["Location"]).to eq("/features/refactor-images") end it "should not have an application_breadcrumb_href by default" do