Sha256: 75237329afb00a97178876ef8279179d86572f8248f10734dc3205dc889f4a89

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

require 'helper'

RSpec.describe Flipper::UI::Actions::Gate 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/non-existent-gate" do
    before do
      post "/features/search/non-existent-gate",
        {"authenticity_token" => token},
        "rack.session" => session
    end

    it "responds with redirect" do
      expect(last_response.status).to be(302)
    end

    it "escapes error message" do
      expect(last_response.headers["Location"]).to eq("/features/search?error=%22non-existent-gate%22+gate+does+not+exist+therefore+it+cannot+be+updated.")
    end

    it "renders error in template" do
      follow_redirect!
      expect(last_response.body).to match(/non-existent-gate.*gate does not exist/)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
flipper-ui-0.10.2 spec/flipper/ui/actions/gate_spec.rb
flipper-ui-0.10.1 spec/flipper/ui/actions/gate_spec.rb
flipper-ui-0.10.0 spec/flipper/ui/actions/gate_spec.rb
flipper-ui-0.9.2 spec/flipper/ui/actions/gate_spec.rb