Sha256: 9e392271c27fabe1c22efd9cea74725d221993150f331ba1f3865804f4c9eb84

Contents?: true

Size: 1.27 KB

Versions: 7

Compression:

Stored size: 1.27 KB

Contents

require 'helper'

RSpec.describe Flipper::UI::Actions::PercentageOfTimeGate do
  describe "POST /features/:feature/percentage_of_time" do
    context "with valid value" do
      before do
        post "features/search/percentage_of_time",
          {"value" => "24", "authenticity_token" => "a"},
          "rack.session" => {"_csrf_token" => "a"}
      end

      it "enables the feature" do
        expect(flipper[:search].percentage_of_time_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_time",
          {"value" => "555", "authenticity_token" => "a"},
          "rack.session" => {"_csrf_token" => "a"}
      end

      it "does not change value" do
        expect(flipper[:search].percentage_of_time_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+time+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

7 entries across 7 versions & 1 rubygems

Version Path
flipper-ui-0.9.1 spec/flipper/ui/actions/percentage_of_time_gate_spec.rb
flipper-ui-0.9.0 spec/flipper/ui/actions/percentage_of_time_gate_spec.rb
flipper-ui-0.9.0.beta1 spec/flipper/ui/actions/percentage_of_time_gate_spec.rb
flipper-ui-0.8.0 spec/flipper/ui/actions/percentage_of_time_gate_spec.rb
flipper-ui-0.7.5 spec/flipper/ui/actions/percentage_of_time_gate_spec.rb
flipper-ui-0.7.4 spec/flipper/ui/actions/percentage_of_time_gate_spec.rb
flipper-ui-0.7.3 spec/flipper/ui/actions/percentage_of_time_gate_spec.rb