Sha256: 58b32905a6934f35b5e92fe7d03d2b28f7e140888ce2bc91fc4b5b56070f99ae

Contents?: true

Size: 1017 Bytes

Versions: 32

Compression:

Stored size: 1017 Bytes

Contents

require 'spec_helper'

describe Spree::Admin::GeneralSettingsController, type: :controller do
  let(:user) { create(:user) }

  before do
    allow(controller).to receive_messages :spree_current_user => user
    user.spree_roles << Spree::Role.find_or_create_by(name: 'admin')
  end

  describe '#clear_cache' do
    subject { spree_post :clear_cache }

    shared_examples 'a HTTP 204 response' do
      it 'grant access to users with an admin role' do
        subject
        expect(response.status).to eq(204)
      end
    end

    context 'when no callback' do
      it_behaves_like 'a HTTP 204 response'
    end

    context 'when callback implemented' do
      Spree::Admin::GeneralSettingsController.class_eval do
        custom_callback(:clear_cache).after :foo

        def foo
          # Make a call to Akamai, CloudFlare, etc invalidation....
        end
      end

      before do
        expect(controller).to receive(:foo).once
      end

      it_behaves_like 'a HTTP 204 response'
    end
  end
end

Version data entries

32 entries across 32 versions & 2 rubygems

Version Path
solidus_backend-1.2.3 spec/controllers/spree/admin/general_settings_controller_spec.rb
solidus_backend-1.1.4 spec/controllers/spree/admin/general_settings_controller_spec.rb
solidus_backend-1.0.7 spec/controllers/spree/admin/general_settings_controller_spec.rb
spree_backend-3.1.5 spec/controllers/spree/admin/general_settings_controller_spec.rb
spree_backend-3.1.4 spec/controllers/spree/admin/general_settings_controller_spec.rb
spree_backend-3.1.3 spec/controllers/spree/admin/general_settings_controller_spec.rb
spree_backend-3.1.2 spec/controllers/spree/admin/general_settings_controller_spec.rb
spree_backend-3.0.10 spec/controllers/spree/admin/general_settings_controller_spec.rb
spree_backend-3.1.1 spec/controllers/spree/admin/general_settings_controller_spec.rb
spree_backend-3.1.0 spec/controllers/spree/admin/general_settings_controller_spec.rb
spree_backend-3.1.0.rc4 spec/controllers/spree/admin/general_settings_controller_spec.rb
spree_backend-3.0.9 spec/controllers/spree/admin/general_settings_controller_spec.rb
spree_backend-3.1.0.rc3 spec/controllers/spree/admin/general_settings_controller_spec.rb
spree_backend-3.1.0.rc2 spec/controllers/spree/admin/general_settings_controller_spec.rb
spree_backend-3.1.0.rc1 spec/controllers/spree/admin/general_settings_controller_spec.rb
solidus_backend-1.0.6 spec/controllers/spree/admin/general_settings_controller_spec.rb
spree_backend-3.0.8 spec/controllers/spree/admin/general_settings_controller_spec.rb
solidus_backend-1.2.2 spec/controllers/spree/admin/general_settings_controller_spec.rb
spree_backend-3.0.7 spec/controllers/spree/admin/general_settings_controller_spec.rb
solidus_backend-1.2.1 spec/controllers/spree/admin/general_settings_controller_spec.rb