Module: Spree::TestingSupport::AuthorizationHelpers::Request

Defined in:
lib/spree/testing_support/authorization_helpers.rb

Defined Under Namespace

Classes: SuperAbility

Instance Method Summary collapse

Instance Method Details

#custom_authorization!(&block) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/spree/testing_support/authorization_helpers.rb', line 33

def custom_authorization!(&block)
  ability = Class.new do
    include CanCan::Ability
    define_method(:initialize, block)
  end
  after(:all) do
    Spree::Ability.remove_ability(ability)
  end
  before(:all) do
    Spree::Ability.register_ability(ability)
  end
end

#stub_authorization!Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/spree/testing_support/authorization_helpers.rb', line 22

def stub_authorization!
  after(:all) do
    ability = Spree::TestingSupport::AuthorizationHelpers::Request::SuperAbility
    Spree::Ability.remove_ability(ability)
  end
  before(:all) do
    ability = Spree::TestingSupport::AuthorizationHelpers::Request::SuperAbility
    Spree::Ability.register_ability(ability)
  end
end