Sha256: 52f8eb4db8d164ff0d9d02f4704dca7d2cb48de52d5cadf791c097a44aa39263

Contents?: true

Size: 1.05 KB

Versions: 15

Compression:

Stored size: 1.05 KB

Contents

require 'helper'

RSpec.describe Flipper::UI::Actions::Gate do
  let(:token) do
    if Rack::Protection::AuthenticityToken.respond_to?(:random_token)
      Rack::Protection::AuthenticityToken.random_token
    else
      'a'
    end
  end
  let(:session) do
    { :csrf => token, 'csrf' => token, '_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

    # rubocop:disable Metrics/LineLength
    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
    # rubocop:enable Metrics/LineLength

    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

15 entries across 15 versions & 1 rubygems

Version Path
flipper-ui-0.15.0 spec/flipper/ui/actions/gate_spec.rb
flipper-ui-0.14.0 spec/flipper/ui/actions/gate_spec.rb
flipper-ui-0.13.0 spec/flipper/ui/actions/gate_spec.rb
flipper-ui-0.13.0.beta1 spec/flipper/ui/actions/gate_spec.rb
flipper-ui-0.12.2 spec/flipper/ui/actions/gate_spec.rb
flipper-ui-0.12.1 spec/flipper/ui/actions/gate_spec.rb
flipper-ui-0.12.0 spec/flipper/ui/actions/gate_spec.rb
flipper-ui-0.11.0 spec/flipper/ui/actions/gate_spec.rb
flipper-ui-0.11.0.rc1 spec/flipper/ui/actions/gate_spec.rb
flipper-ui-0.11.0.beta9 spec/flipper/ui/actions/gate_spec.rb
flipper-ui-0.11.0.beta8 spec/flipper/ui/actions/gate_spec.rb
flipper-ui-0.11.0.beta7 spec/flipper/ui/actions/gate_spec.rb
flipper-ui-0.11.0.beta6 spec/flipper/ui/actions/gate_spec.rb
flipper-ui-0.11.0.beta5 spec/flipper/ui/actions/gate_spec.rb
flipper-ui-0.11.0.beta4 spec/flipper/ui/actions/gate_spec.rb