Sha256: 0beaf2e888f66316a7bc1603fda0b0d084416387acbdc2e9d82d8ac4b5167b8c

Contents?: true

Size: 1.59 KB

Versions: 7

Compression:

Stored size: 1.59 KB

Contents

require 'spec_helper'

RSpec.describe "Spree::Admin::Bolts", type: :request do
  stub_authorization!

  let(:bolt_configuration_params) {
    {
      environment: 'sandbox',
      api_key: SecureRandom.hex,
      signing_secret: SecureRandom.hex,
      publishable_key: SecureRandom.hex
    }
  }

  describe "GET /show" do
    it 'returns a successful response' do
      get '/admin/bolt'
      expect(response.status).to eq 200
    end

    it 'creates a new SolidusBolt::BoltConfiguration record if no records are present' do
      expect { get '/admin/bolt' }.to change { SolidusBolt::BoltConfiguration.count }.by(1)
    end
  end

  describe "GET /edit" do
    let(:bolt_configuration) { create(:bolt_configuration) }

    it 'returns a successful response' do
      get '/admin/bolt/edit'
      expect(response.status).to eq 200
    end
  end

  describe "PUT /update" do
    subject(:request) {
      put '/admin/bolt', params: { solidus_bolt_bolt_configuration: bolt_configuration_params }
    }

    let(:bolt_configuration) { create(:bolt_configuration) }

    it 'successfully redirects' do
      request
      expect(response.status).to eq 302
    end

    it 'redirects to index' do
      request
      expect(response).to redirect_to '/admin/bolt'
    end

    it 'successfully updates the bolt configuration' do
      request

      updated_attributes = SolidusBolt::BoltConfiguration.fetch.attributes.slice(
        'environment',
        'api_key',
        'signing_secret',
        'publishable_key'
      )

      expect(updated_attributes).to eq(bolt_configuration_params.deep_stringify_keys)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
solidus_bolt-0.7.2 spec/requests/spree/admin/bolt_spec.rb
solidus_bolt-0.7.1 spec/requests/spree/admin/bolt_spec.rb
solidus_bolt-0.7.0 spec/requests/spree/admin/bolt_spec.rb
solidus_bolt-0.6.0 spec/requests/spree/admin/bolt_spec.rb
solidus_bolt-0.5.0 spec/requests/spree/admin/bolt_spec.rb
solidus_bolt-0.4.0 spec/requests/spree/admin/bolt_spec.rb
solidus_bolt-0.3.0 spec/requests/spree/admin/bolt_spec.rb