Sha256: d443b8f8e3a4e1f003c0c0154109ce2d9e9044f50cf05d217fa00ab7991ea5af

Contents?: true

Size: 1.26 KB

Versions: 4

Compression:

Stored size: 1.26 KB

Contents

require 'helper'
require 'flipper/ui/actor'

describe Flipper::UI::Actions::PercentageOfActorsGate do
  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" => "a"},
          "rack.session" => {:csrf => "a"}
      end

      it "enables the feature" do
        flipper[:search].percentage_of_actors_value.should be(24)
      end

      it "redirects back to feature" do
        last_response.status.should be(302)
        last_response.headers["Location"].should eq("/features/search")
      end
    end

    context "with invalid value" do
      before do
        post "features/search/percentage_of_actors",
          {"value" => "555", "authenticity_token" => "a"},
          "rack.session" => {:csrf => "a"}
      end

      it "does not change value" do
        flipper[:search].percentage_of_actors_value.should be(0)
      end

      it "redirects back to feature" do
        last_response.status.should be(302)
        last_response.headers["Location"].should 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

Version Path
flipper-ui-0.7.0.beta4 spec/flipper/ui/actions/percentage_of_actors_gate_spec.rb
flipper-ui-0.2.0.beta5 spec/flipper/ui/actions/percentage_of_actors_gate_spec.rb
flipper-ui-0.2.0.beta4 spec/flipper/ui/actions/percentage_of_actors_gate_spec.rb
flipper-ui-0.2.0.beta3 spec/flipper/ui/actions/percentage_of_actors_gate_spec.rb