Sha256: 352c3f366cd3055ac72fb63bdefbc54c95a767c4fc1d8dce9d58d198f55e7d8c

Contents?: true

Size: 1.64 KB

Versions: 1

Compression:

Stored size: 1.64 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 => "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 => "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

1 entries across 1 versions & 1 rubygems

Version Path
flipper-ui-0.7.2 spec/flipper/ui/actions/feature_spec.rb