Sha256: baf1a463a0b401a93f7e4c81f31ac42f76db408179e519c37c056ad549524975

Contents?: true

Size: 910 Bytes

Versions: 1

Compression:

Stored size: 910 Bytes

Contents

module AuthorizationHelpers
  module Controller
    def stub_authorization!
      let(:ability_user) { stub_model(Spree::LegacyUser) }

      before do
        controller.stub(:try_spree_current_user => ability_user)
        controller.should_receive(:authorize!).and_return(true)
      end
    end
  end

  module Request
    class SuperAbility
      include CanCan::Ability

      def initialize(user)
        # allow anyone to perform index on Order
        can :manage, :all
      end
    end

    def stub_authorization!
      before(:all) { Spree::Ability.register_ability(AuthorizationHelpers::Request::SuperAbility) }
      after(:all) { Spree::Ability.remove_ability(AuthorizationHelpers::Request::SuperAbility) }
    end
  end
end

RSpec.configure do |config|
  config.extend AuthorizationHelpers::Controller, :type => :controller
  config.extend AuthorizationHelpers::Request, :type => :request
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spree_core-1.3.2 lib/spree/core/testing_support/authorization_helpers.rb