Sha256: 1dbcbca7327066700dd63c339e6dd172b938a27de865c0bbdc3549d5d0ec310e

Contents?: true

Size: 1.66 KB

Versions: 7

Compression:

Stored size: 1.66 KB

Contents

require 'helper'

RSpec.describe Flipper::UI::Actions::Feature do
  describe "DELETE /features/:feature" do
    before do
      flipper.enable :search
      delete "/features/search",
        {"authenticity_token" => "a"},
        "rack.session" => {"_csrf_token" => "a"}
    end

    it "removes feature" do
      expect(flipper.features.map(&:key)).not_to include("search")
    end

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

  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"}
    end

    it "removes feature" do
      expect(flipper.features.map(&:key)).not_to include("search")
    end

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

  describe "GET /features/:feature" do
    before do
      get "/features/search"
    end

    it "responds with success" do
      expect(last_response.status).to be(200)
    end

    it "renders template" do
      expect(last_response.body).to include("search")
      expect(last_response.body).to include("Enable")
      expect(last_response.body).to include("Disable")
      expect(last_response.body).to include("Actors")
      expect(last_response.body).to include("Groups")
      expect(last_response.body).to include("Percentage of Time")
      expect(last_response.body).to include("Percentage of Actors")
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

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