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

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

Instance Method Summary collapse

Methods included from CustomAbility

#build_ability

Instance Method Details

#custom_authorization!(&block) ⇒ Object


44
45
46
47
48
49
50
51
52
# File 'lib/spree/testing_support/authorization_helpers.rb', line 44

def custom_authorization!(&block)
  ability = build_ability(&block)
  after(:all) do
    Spree::Ability.remove_ability(ability)
  end
  before(:all) do
    Spree::Ability.register_ability(ability)
  end
end

#stub_authorization!Object


28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/spree/testing_support/authorization_helpers.rb', line 28

def stub_authorization!
  ability = build_ability

  after(:all) do
    Spree::Ability.remove_ability(ability)
  end

  before(:all) do
    Spree::Ability.register_ability(ability)
  end

  before do
    allow_any_instance_of(Api::BaseController).to receive(:try_spree_current_user).and_return(Spree.user_class.new)
  end
end