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



50
51
52
53
54
55
56
57
58
# File 'lib/spree/testing_support/authorization_helpers.rb', line 50

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



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

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(Spree.user_class).to receive(:find_by).
                                 with(hash_including(:spree_api_key)).
                                 and_return(Spree.user_class.new)
  end
end