Sha256: b49bc0a49dcebdd727ff067e55976f46a2f33088a0105c8b5f44fbe657915276

Contents?: true

Size: 1.71 KB

Versions: 6

Compression:

Stored size: 1.71 KB

Contents

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

  describe 'GET /features/new when an adpter is set to readonly' do
    before do
      allow(flipper).to receive(:read_only?) { true }
      get '/features/new'
    end

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

    it 'shows that the UI is currently read-only mode' do
      expect(last_response.body).to include('The UI is currently in read only mode.')
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
flipper-ui-1.2.2 spec/flipper/ui/actions/add_feature_spec.rb
flipper-ui-1.2.1 spec/flipper/ui/actions/add_feature_spec.rb
flipper-ui-1.2.0 spec/flipper/ui/actions/add_feature_spec.rb
flipper-ui-1.1.2 spec/flipper/ui/actions/add_feature_spec.rb
flipper-ui-1.1.1 spec/flipper/ui/actions/add_feature_spec.rb
flipper-ui-1.1.0 spec/flipper/ui/actions/add_feature_spec.rb