Sha256: 587c89259d7f3ba54516771be379896906003db228a652a44a2020e6e0788211
Contents?: true
Size: 1.59 KB
Versions: 4
Compression:
Stored size: 1.59 KB
Contents
require 'helper' RSpec.describe Flipper::UI::Actions::PercentageOfActorsGate 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 "POST /features/:feature/percentage_of_actors" do context "with valid value" do before do post "features/search/percentage_of_actors", {"value" => "24", "authenticity_token" => token}, "rack.session" => session end it "enables the feature" do expect(flipper[:search].percentage_of_actors_value).to be(24) end it "redirects back to feature" do expect(last_response.status).to be(302) expect(last_response.headers["Location"]).to eq("/features/search") end end context "with invalid value" do before do post "features/search/percentage_of_actors", {"value" => "555", "authenticity_token" => token}, "rack.session" => session end it "does not change value" do expect(flipper[:search].percentage_of_actors_value).to be(0) end it "redirects back to feature" do expect(last_response.status).to be(302) expect(last_response.headers["Location"]).to eq("/features/search?error=Invalid+percentage+of+actors+value%3A+value+must+be+a+positive+number+less+than+or+equal+to+100%2C+but+was+555") end end end end
Version data entries
4 entries across 4 versions & 1 rubygems