Sha256: a908b39bdab3fc615915af6b38b9bc6bcefe39af907a6b99681deed963cd042a

Contents?: true

Size: 1.33 KB

Versions: 23

Compression:

Stored size: 1.33 KB

Contents

require 'helper'

RSpec.describe Flipper::UI::Actions::AddFeature do
  describe 'GET /features/new with feature_creation_enabled set to true' do
    before do
      @original_feature_creation_enabled = Flipper::UI.configuration.feature_creation_enabled
      Flipper::UI.configuration.feature_creation_enabled = true
      get '/features/new'
    end

    after do
      Flipper::UI.configuration.feature_creation_enabled = @original_feature_creation_enabled
    end

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

    it 'renders template' do
      form = '<form action="/features" method="post" class="form-inline mb-2">'
      expect(last_response.body).to include(form)
    end
  end

  describe 'GET /features/new with feature_creation_enabled set to false' do
    before do
      @original_feature_creation_enabled = Flipper::UI.configuration.feature_creation_enabled
      Flipper::UI.configuration.feature_creation_enabled = false
      get '/features/new'
    end

    after do
      Flipper::UI.configuration.feature_creation_enabled = @original_feature_creation_enabled
    end

    it 'returns 403' do
      expect(last_response.status).to be(403)
    end

    it 'renders feature creation disabled template' do
      expect(last_response.body).to include('Feature creation is disabled.')
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
flipper-ui-0.22.2 spec/flipper/ui/actions/add_feature_spec.rb
flipper-ui-0.22.1 spec/flipper/ui/actions/add_feature_spec.rb
flipper-ui-0.22.0 spec/flipper/ui/actions/add_feature_spec.rb
flipper-ui-0.21.0 spec/flipper/ui/actions/add_feature_spec.rb
flipper-ui-0.21.0.rc2 spec/flipper/ui/actions/add_feature_spec.rb
flipper-ui-0.21.0.rc1 spec/flipper/ui/actions/add_feature_spec.rb
flipper-ui-0.20.4 spec/flipper/ui/actions/add_feature_spec.rb
flipper-ui-0.20.3 spec/flipper/ui/actions/add_feature_spec.rb
flipper-ui-0.20.2 spec/flipper/ui/actions/add_feature_spec.rb
flipper-ui-0.20.1 spec/flipper/ui/actions/add_feature_spec.rb
flipper-ui-0.20.0 spec/flipper/ui/actions/add_feature_spec.rb
flipper-ui-0.20.0.beta3 spec/flipper/ui/actions/add_feature_spec.rb
flipper-ui-0.20.0.beta2 spec/flipper/ui/actions/add_feature_spec.rb
flipper-ui-0.20.0.beta1 spec/flipper/ui/actions/add_feature_spec.rb
flipper-ui-0.19.1 spec/flipper/ui/actions/add_feature_spec.rb
flipper-ui-0.19.0 spec/flipper/ui/actions/add_feature_spec.rb
flipper-ui-0.18.0 spec/flipper/ui/actions/add_feature_spec.rb
flipper-ui-0.17.2 spec/flipper/ui/actions/add_feature_spec.rb
flipper-ui-0.17.1 spec/flipper/ui/actions/add_feature_spec.rb
flipper-ui-0.16.2 spec/flipper/ui/actions/add_feature_spec.rb