Class: RSpec::Authorization::Adapters::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/authorization/adapters/resource.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(privilege) ⇒ Resource


11
12
13
# File 'lib/rspec/authorization/adapters/resource.rb', line 11

def initialize(privilege)
  @privilege = privilege
end

Instance Attribute Details

#negated_resultsObject (readonly)

Returns the value of attribute negated_results


4
5
6
# File 'lib/rspec/authorization/adapters/resource.rb', line 4

def negated_results
  @negated_results
end

#privilegeObject (readonly)

Returns the value of attribute privilege


4
5
6
# File 'lib/rspec/authorization/adapters/resource.rb', line 4

def privilege
  @privilege
end

#resultsObject (readonly)

Returns the value of attribute results


4
5
6
# File 'lib/rspec/authorization/adapters/resource.rb', line 4

def results
  @results
end

Instance Method Details

#forbidden?Boolean


31
32
33
# File 'lib/rspec/authorization/adapters/resource.rb', line 31

def forbidden?
  permitted_or_forbidden?(:forbidden_for?, :permitted_for?)
end

#permitted?Boolean


27
28
29
# File 'lib/rspec/authorization/adapters/resource.rb', line 27

def permitted?
  permitted_or_forbidden?(:permitted_for?, :forbidden_for?)
end

#run(actions) ⇒ Object


15
16
17
18
19
20
# File 'lib/rspec/authorization/adapters/resource.rb', line 15

def run(actions)
  actions.map do |action|
    request = Request.new(controller_class, action, role)
    [action, request.response.status != 403]
  end
end

#run_allObject


22
23
24
25
# File 'lib/rspec/authorization/adapters/resource.rb', line 22

def run_all
  requests
  negated_requests
end