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

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

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Methods included from CustomAbility

#build_ability

Instance Method Details

#custom_authorization!(&block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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

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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# 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(Spree.user_class).to receive(:find_by).
                                 with(hash_including(:spree_api_key)).
                                 and_return(Spree.user_class.new)
  end
end