rolypoly 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.ruby-version +1 -1
- data/README.md +43 -0
- data/lib/rolypoly/controller_role_dsl.rb +13 -5
- data/lib/rolypoly/role_gatekeeper.rb +19 -7
- data/lib/rolypoly/version.rb +1 -1
- data/rolypoly.gemspec +3 -3
- data/spec/lib/rolypoly/controller_role_dsl_spec.rb +53 -5
- data/spec/lib/rolypoly/role_gatekeeper_spec.rb +104 -62
- data/spec/spec_helper.rb +0 -1
- metadata +19 -17
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
ZjA1MmZkZmJhM2Q2NDAzZTdhNWI0YjQ5NzM3NjI2Y2MwYTQ5MDc4Yw==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8cbaff5553d1ea031bdb189ab537a9ff7c72aadd
|
4
|
+
data.tar.gz: 332873a3a06a886b821e12a0977ae9da8a13a781
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
NDNiMmJiMjFiZGQwOGM2MjgyOTlkNWJlOGYwNWMwMTlkMTY4NTdhN2YwOTdk
|
11
|
-
YzJlZjQ5N2RjZjliNjE2M2JhNTVmNGRiMjE1MTUzNmFiMzYyMjM=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
YTlhNWY1MzhjNDEzZDE5OTFmNWRiNzViZTY0NTM5OGQwNzI4YjIxYzc2NDNi
|
14
|
-
N2Q4MjFiYTBlNjY2MTNkYWYyZTJlOTlhOGIxZTMwMmJmZDcxNjU3ODY1ZGY0
|
15
|
-
ZGJjY2FlZDZjMTZmYzcxNTI4YmY4NWVjNGFlZjUzMGZkZWUzYWU=
|
6
|
+
metadata.gz: 1e25dbecd6ba8902d65f210a800179c6e63908bd24daf6f77775c314ea22d9e3418abfbffc06c08f496157bcb1b7462faf30d73fef054844481026851496b0d5
|
7
|
+
data.tar.gz: f76e7eebd9c64d69e4bc098a2730304dab04922dbe0e3206a77227ca4d0e1b3bc9ac838e8f3e4313393b17d972d3823566b840bbf72fdccb85d6d12c1c6c4f7e
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.2.0
|
data/README.md
CHANGED
@@ -93,6 +93,49 @@ class ProfilesController < ApplicationController
|
|
93
93
|
end
|
94
94
|
```
|
95
95
|
|
96
|
+
# Allow roles with a resource
|
97
|
+
`allow_with_resource` acts similarly to `allow` but executes a resource check on the `SomeCustomerRoleObject` to access the endpoint.
|
98
|
+
|
99
|
+
This requires a method to be defined on `SomeCustomRoleObject` that checks if the resource is valid for that role.
|
100
|
+
|
101
|
+
The `role_resource` needs to be defined on the controller to pass the resource that the role will be validated against.
|
102
|
+
If `role_resource` is not defined it will be defaulted to an empty hash `{}`.
|
103
|
+
|
104
|
+
|
105
|
+
```ruby
|
106
|
+
class SomeCustomRoleObject
|
107
|
+
def resource?(resource)
|
108
|
+
self.resources.includes?(resource)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
class ProfilesController < ApplicationController
|
113
|
+
allow_with_resource(:admin).to_access(:index)
|
114
|
+
allow_with_resource(:owner).to_access(:edit)
|
115
|
+
publicize(:show)
|
116
|
+
|
117
|
+
def index
|
118
|
+
current_roles # => [#<SomeCustomRoleObject to_role_string: "admin", resource?: true >]
|
119
|
+
end
|
120
|
+
|
121
|
+
def edit # Raises permission error before entering this
|
122
|
+
current_roles # => []
|
123
|
+
end
|
124
|
+
|
125
|
+
def show
|
126
|
+
current_roles # => []
|
127
|
+
end
|
128
|
+
|
129
|
+
private def current_user_roles
|
130
|
+
current_user.roles # => [#<SomeCustomRoleObject to_role_string: "admin", resource?: true>, #<SomeCustomRoleObject to_role_string: "scorekeeper", resource?: false>]
|
131
|
+
end
|
132
|
+
|
133
|
+
private def role_resource
|
134
|
+
{ resource: params[:resource_id] }
|
135
|
+
end
|
136
|
+
end
|
137
|
+
```
|
138
|
+
|
96
139
|
## Contributing
|
97
140
|
|
98
141
|
1. Fork it
|
@@ -17,6 +17,10 @@ module Rolypoly
|
|
17
17
|
unless sub.method_defined? :current_user_roles
|
18
18
|
define_method(:current_user_roles) { [] }
|
19
19
|
end
|
20
|
+
|
21
|
+
unless sub.method_defined? :role_resource
|
22
|
+
define_method(:role_resource) { {} }
|
23
|
+
end
|
20
24
|
sub.send :extend, ClassMethods
|
21
25
|
end
|
22
26
|
|
@@ -31,8 +35,8 @@ module Rolypoly
|
|
31
35
|
def current_roles
|
32
36
|
return [] if rolypoly_gatekeepers.empty?
|
33
37
|
current_gatekeepers.reduce([]) { |array, gatekeeper|
|
34
|
-
if gatekeeper.role?
|
35
|
-
array += Array(gatekeeper.allowed_roles(current_user_roles, action_name))
|
38
|
+
if gatekeeper.role?(current_user_roles, role_resource)
|
39
|
+
array += Array(gatekeeper.allowed_roles(current_user_roles, action_name, role_resource))
|
36
40
|
end
|
37
41
|
array
|
38
42
|
}
|
@@ -52,7 +56,7 @@ module Rolypoly
|
|
52
56
|
def rolypoly_role_access?
|
53
57
|
rolypoly_gatekeepers.empty? ||
|
54
58
|
rolypoly_gatekeepers.any? { |gatekeeper|
|
55
|
-
gatekeeper.allow?
|
59
|
+
gatekeeper.allow?(current_roles, action_name, role_resource)
|
56
60
|
}
|
57
61
|
end
|
58
62
|
private :rolypoly_role_access?
|
@@ -75,6 +79,10 @@ module Rolypoly
|
|
75
79
|
build_gatekeeper roles, nil
|
76
80
|
end
|
77
81
|
|
82
|
+
def allow_with_resource(*roles)
|
83
|
+
build_gatekeeper roles, nil, true
|
84
|
+
end
|
85
|
+
|
78
86
|
def publicize(*actions)
|
79
87
|
restrict(*actions).to_none
|
80
88
|
end
|
@@ -90,8 +98,8 @@ module Rolypoly
|
|
90
98
|
end
|
91
99
|
end
|
92
100
|
|
93
|
-
def build_gatekeeper(roles, actions)
|
94
|
-
RoleGatekeeper.new(roles, actions).tap { |gatekeeper|
|
101
|
+
def build_gatekeeper(roles, actions, require_resource = false)
|
102
|
+
RoleGatekeeper.new(roles, actions, require_resource).tap { |gatekeeper|
|
95
103
|
rolypoly_gatekeepers << gatekeeper
|
96
104
|
}
|
97
105
|
end
|
@@ -2,9 +2,10 @@ require 'set'
|
|
2
2
|
module Rolypoly
|
3
3
|
class RoleGatekeeper
|
4
4
|
attr_reader :roles
|
5
|
-
def initialize(roles, actions)
|
5
|
+
def initialize(roles, actions, require_resource)
|
6
6
|
self.roles = Set.new Array(roles).map(&:to_s)
|
7
7
|
self.actions = Set.new Array(actions).map(&:to_s)
|
8
|
+
self.require_resource = require_resource
|
8
9
|
self.all_actions = false
|
9
10
|
self.public = false
|
10
11
|
end
|
@@ -31,14 +32,14 @@ module Rolypoly
|
|
31
32
|
self.all_actions = true
|
32
33
|
end
|
33
34
|
|
34
|
-
def allow?(current_roles, action)
|
35
|
+
def allow?(current_roles, action, resource)
|
35
36
|
action?(action) &&
|
36
|
-
role?(current_roles)
|
37
|
+
role?(current_roles, resource)
|
37
38
|
end
|
38
39
|
|
39
|
-
def allowed_roles(current_roles, action)
|
40
|
+
def allowed_roles(current_roles, action, resource)
|
40
41
|
return [] if public? || !action?(action)
|
41
|
-
match_roles(current_roles)
|
42
|
+
match_roles(current_roles, resource)
|
42
43
|
end
|
43
44
|
|
44
45
|
def all_public
|
@@ -46,7 +47,8 @@ module Rolypoly
|
|
46
47
|
self.all_actions = true
|
47
48
|
end
|
48
49
|
|
49
|
-
def role?(check_roles)
|
50
|
+
def role?(check_roles, resource)
|
51
|
+
check_roles = filter_roles_by_resource(check_roles, resource)
|
50
52
|
check_roles = Set.new sanitize_role_input(check_roles)
|
51
53
|
public? || !(check_roles & roles).empty?
|
52
54
|
end
|
@@ -65,8 +67,10 @@ module Rolypoly
|
|
65
67
|
attr_accessor :actions
|
66
68
|
attr_accessor :all_actions
|
67
69
|
attr_accessor :public
|
70
|
+
attr_accessor :require_resource
|
68
71
|
|
69
|
-
def match_roles(check_roles)
|
72
|
+
def match_roles(check_roles, resource)
|
73
|
+
check_roles = filter_roles_by_resource(check_roles, resource)
|
70
74
|
check_roles.reduce([]) { |array, role_object|
|
71
75
|
array << role_object if roles.include?(sanitize_role_object(role_object))
|
72
76
|
array
|
@@ -74,6 +78,14 @@ module Rolypoly
|
|
74
78
|
end
|
75
79
|
private :match_roles
|
76
80
|
|
81
|
+
def filter_roles_by_resource(check_roles, resource)
|
82
|
+
return check_roles if check_roles.nil? || !require_resource
|
83
|
+
check_roles.select do |check_role|
|
84
|
+
check_role.respond_to?(:resource?) && check_role.resource?(resource)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
private :filter_roles_by_resource
|
88
|
+
|
77
89
|
def sanitize_role_input(role_objects)
|
78
90
|
Array(role_objects).map { |r| sanitize_role_object(r) }
|
79
91
|
end
|
data/lib/rolypoly/version.rb
CHANGED
data/rolypoly.gemspec
CHANGED
@@ -6,8 +6,8 @@ require 'rolypoly/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "rolypoly"
|
8
8
|
spec.version = Rolypoly::VERSION
|
9
|
-
spec.authors = ["Jon Phenow"]
|
10
|
-
spec.email = ["j.phenow@gmail.com"]
|
9
|
+
spec.authors = ["Jon Phenow", "Jake Waletzko"]
|
10
|
+
spec.email = ["j.phenow@gmail.com", "jnwaletzko@gmail.com"]
|
11
11
|
spec.description = %q{Tools for handling per-action and per-app Role authorization}
|
12
12
|
spec.summary = %q{Tools for handling per-action and per-app Role authorization}
|
13
13
|
spec.homepage = "https://github.com/sportngin/rolypoly"
|
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_development_dependency "bundler", "~> 1.
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.8"
|
22
22
|
spec.add_development_dependency "rake"
|
23
23
|
spec.add_development_dependency "rspec"
|
24
24
|
end
|
@@ -15,6 +15,7 @@ module Rolypoly
|
|
15
15
|
subject { example_controller }
|
16
16
|
it { should respond_to :restrict }
|
17
17
|
it { should respond_to :allow }
|
18
|
+
it { should respond_to :allow_with_resource }
|
18
19
|
|
19
20
|
describe "setting up with DSL" do
|
20
21
|
describe "from allow side" do
|
@@ -23,14 +24,15 @@ module Rolypoly
|
|
23
24
|
before do
|
24
25
|
subject.allow(:admin).to_access(:index)
|
25
26
|
subject.publicize(:landing)
|
26
|
-
controller_instance.
|
27
|
+
allow(controller_instance).to receive(:current_user_roles).and_return(current_user_roles)
|
28
|
+
allow(controller_instance).to receive(:action_name).and_return(action_name)
|
27
29
|
end
|
28
30
|
|
29
31
|
describe "#index" do
|
30
32
|
let(:action_name) { "index" }
|
31
33
|
|
32
34
|
it "is not public" do
|
33
|
-
controller_instance.
|
35
|
+
expect(controller_instance).to_not be_public
|
34
36
|
end
|
35
37
|
|
36
38
|
it "allows admin access" do
|
@@ -39,7 +41,7 @@ module Rolypoly
|
|
39
41
|
end
|
40
42
|
|
41
43
|
it "can get current_roles from controller" do
|
42
|
-
controller_instance.current_roles.
|
44
|
+
expect(controller_instance.current_roles).to eq([RoleObject.new(:admin)])
|
43
45
|
end
|
44
46
|
end
|
45
47
|
|
@@ -51,7 +53,7 @@ module Rolypoly
|
|
51
53
|
end
|
52
54
|
|
53
55
|
it "is not public" do
|
54
|
-
controller_instance.
|
56
|
+
expect(controller_instance).to_not be_public
|
55
57
|
end
|
56
58
|
end
|
57
59
|
|
@@ -70,11 +72,57 @@ module Rolypoly
|
|
70
72
|
end
|
71
73
|
|
72
74
|
it "is public" do
|
73
|
-
controller_instance.
|
75
|
+
expect(controller_instance).to be_public
|
74
76
|
end
|
75
77
|
end
|
76
78
|
end
|
77
79
|
end
|
80
|
+
|
81
|
+
describe "from allow_with_resource side" do
|
82
|
+
let(:controller_instance) { subject.new }
|
83
|
+
let(:admin_role) { RoleObject.new(:admin) }
|
84
|
+
let(:scorekeeper_role) { RoleObject.new(:scorekeeper) }
|
85
|
+
let(:current_user_roles) { [admin_role, scorekeeper_role] }
|
86
|
+
let(:role_resource) { {resource: 123} }
|
87
|
+
let(:check_access!) { controller_instance.rolypoly_check_role_access! }
|
88
|
+
|
89
|
+
before do
|
90
|
+
subject.allow_with_resource(:admin).to_access(:index)
|
91
|
+
subject.publicize(:landing)
|
92
|
+
allow(admin_role).to receive(:resource?).and_return true
|
93
|
+
allow(controller_instance).to receive(:current_user_roles).and_return(current_user_roles)
|
94
|
+
allow(controller_instance).to receive(:action_name).and_return(action_name)
|
95
|
+
allow(controller_instance).to receive(:role_resource).and_return(role_resource)
|
96
|
+
end
|
97
|
+
|
98
|
+
describe "#index" do
|
99
|
+
let(:action_name) { "index" }
|
100
|
+
|
101
|
+
it { expect(controller_instance).to_not be_public }
|
102
|
+
it { expect{ check_access! }.not_to raise_error }
|
103
|
+
it { expect(controller_instance.current_roles).to eq([RoleObject.new(:admin)])}
|
104
|
+
end
|
105
|
+
|
106
|
+
describe "#show" do
|
107
|
+
let(:action_name) { "show" }
|
108
|
+
|
109
|
+
it { expect{ check_access! }.to raise_error(Rolypoly::FailedRoleCheckError)}
|
110
|
+
it { expect(controller_instance).to_not be_public }
|
111
|
+
end
|
112
|
+
|
113
|
+
describe "#landing" do
|
114
|
+
let(:action_name) { "landing" }
|
115
|
+
|
116
|
+
it { expect{ check_access! }.not_to raise_error }
|
117
|
+
|
118
|
+
describe "with no role" do
|
119
|
+
let(:current_roles) { [] }
|
120
|
+
|
121
|
+
it { expect { check_access! }.not_to raise_error }
|
122
|
+
it { expect(controller_instance).to be_public }
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
78
126
|
end
|
79
127
|
end
|
80
128
|
end
|
@@ -4,102 +4,144 @@ module Rolypoly
|
|
4
4
|
describe RoleGatekeeper do
|
5
5
|
let(:roles) { %w[admin scorekeeper] }
|
6
6
|
let(:actions) { %w[index show] }
|
7
|
+
let(:resource) { {} }
|
7
8
|
|
8
|
-
|
9
|
+
context "resource not required" do
|
10
|
+
subject { described_class.new roles, actions, false }
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should allow scorekeepr access to index" do
|
16
|
-
subject.allow?([:scorekeeper], "index").should be_true
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should not allow scorekeepr access to edit" do
|
20
|
-
subject.allow?([:scorekeeper], "edit").should be_false
|
21
|
-
end
|
22
|
-
|
23
|
-
describe "all public" do
|
24
|
-
before do
|
25
|
-
subject.all_public
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should allow whatever" do
|
29
|
-
subject.allow?(nil, nil).should be_true
|
12
|
+
shared_examples_for "allow should behave correctly" do
|
13
|
+
it "shouldn't auto-allow" do
|
14
|
+
expect(subject.allow?(nil, nil, resource)).to be false
|
30
15
|
end
|
31
16
|
|
32
17
|
it "should allow scorekeepr access to index" do
|
33
|
-
subject.allow?([:scorekeeper], "index").
|
18
|
+
expect(subject.allow?([:scorekeeper], "index", resource)).to be true
|
34
19
|
end
|
35
20
|
|
36
|
-
it "should allow scorekeepr access to edit" do
|
37
|
-
subject.allow?([:scorekeeper], "edit").
|
21
|
+
it "should not allow scorekeepr access to edit" do
|
22
|
+
expect(subject.allow?([:scorekeeper], "edit", resource)).to be false
|
38
23
|
end
|
39
|
-
end
|
40
24
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
25
|
+
describe "all public" do
|
26
|
+
before do
|
27
|
+
subject.all_public
|
28
|
+
end
|
45
29
|
|
46
|
-
|
47
|
-
|
30
|
+
it "should allow whatever" do
|
31
|
+
expect(subject.allow?(nil, nil, resource)).to be true
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should allow scorekeepr access to index" do
|
35
|
+
expect(subject.allow?([:scorekeeper], "index", resource)).to be true
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should allow scorekeepr access to edit" do
|
39
|
+
expect(subject.allow?([:scorekeeper], "edit", resource)).to be true
|
40
|
+
end
|
48
41
|
end
|
49
42
|
|
50
|
-
|
51
|
-
|
52
|
-
|
43
|
+
describe "all roles" do
|
44
|
+
before do
|
45
|
+
subject.to_none
|
46
|
+
end
|
47
|
+
|
48
|
+
it "shouldn't auto-allow" do
|
49
|
+
expect(subject.allow?(nil, nil, resource)).to be false
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should allow scorekeepr access to index" do
|
53
|
+
expect(subject.allow?([:janitor], "index", resource)).to be true
|
54
|
+
expect(subject.allow?([:admin], "index", resource)).to be true
|
55
|
+
end
|
56
|
+
|
57
|
+
it "to should not allow scorekeepr access to edit" do
|
58
|
+
expect(subject.allow?([:scorekeeper], "edit", resource)).to be false
|
59
|
+
expect(subject.allow?([:janitor], "edit", resource)).to be false
|
60
|
+
end
|
53
61
|
end
|
54
62
|
|
55
|
-
|
56
|
-
|
57
|
-
|
63
|
+
describe "all actions" do
|
64
|
+
before do
|
65
|
+
subject.to_all
|
66
|
+
end
|
67
|
+
|
68
|
+
it "shouldn't auto-allow" do
|
69
|
+
expect(subject.allow?(nil, nil, resource)).to be false
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should allow scorekeepr access to index" do
|
73
|
+
expect(subject.allow?([:scorekeeper], "index", resource)).to be true
|
74
|
+
end
|
75
|
+
|
76
|
+
it "shouldn't allow janitor access to any" do
|
77
|
+
expect(subject.allow?([:janitor], "index", resource)).to be false
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should allow scorekeepr access to edit" do
|
81
|
+
expect(subject.allow?([:scorekeeper], "edit", resource)).to be true
|
82
|
+
end
|
58
83
|
end
|
59
84
|
end
|
85
|
+
it_should_behave_like "allow should behave correctly"
|
86
|
+
|
87
|
+
describe "with only roles set" do
|
88
|
+
let(:actions) { [] }
|
60
89
|
|
61
|
-
describe "all actions" do
|
62
90
|
before do
|
63
|
-
subject.
|
91
|
+
subject.to_access(:index, :show)
|
64
92
|
end
|
65
93
|
|
66
|
-
|
67
|
-
|
68
|
-
end
|
94
|
+
it_should_behave_like "allow should behave correctly"
|
95
|
+
end
|
69
96
|
|
70
|
-
|
71
|
-
|
72
|
-
end
|
97
|
+
describe "with only actions set" do
|
98
|
+
let(:roles) { [] }
|
73
99
|
|
74
|
-
|
75
|
-
subject.
|
100
|
+
before do
|
101
|
+
subject.to(:admin, :scorekeeper)
|
76
102
|
end
|
77
103
|
|
78
|
-
|
79
|
-
|
104
|
+
it_should_behave_like "allow should behave correctly"
|
105
|
+
end
|
106
|
+
|
107
|
+
describe "with resource defined" do
|
108
|
+
let(:resource) { [organization: 123] }
|
109
|
+
|
110
|
+
before do
|
111
|
+
subject.to(:admin, :scorekeeper)
|
80
112
|
end
|
113
|
+
|
114
|
+
it_should_behave_like "allow should behave correctly"
|
81
115
|
end
|
82
116
|
end
|
83
|
-
it_should_behave_like "allow should behave correctly"
|
84
117
|
|
85
|
-
|
86
|
-
let(:
|
118
|
+
context "resource required" do
|
119
|
+
let(:scorekeeper_role) { RoleObject.new(:scorekeeper) }
|
120
|
+
|
121
|
+
subject { described_class.new roles, actions, true }
|
122
|
+
|
123
|
+
describe "resource does not match" do
|
124
|
+
before do
|
125
|
+
allow(scorekeeper_role).to receive(:resource?).and_return false
|
126
|
+
allow(scorekeeper_role).to receive(:to_role_string).and_return "scorekeeper"
|
127
|
+
end
|
87
128
|
|
88
|
-
|
89
|
-
subject.
|
129
|
+
it { expect(subject.allow?(nil, nil, resource)).to be false }
|
130
|
+
it { expect(subject.allow?([scorekeeper_role], "index", resource)).to be false }
|
131
|
+
it { expect(subject.allow?([scorekeeper_role], "edit", resource)).to be false }
|
90
132
|
end
|
91
133
|
|
92
|
-
|
93
|
-
|
134
|
+
describe "resource matches" do
|
135
|
+
let(:resource) { {resource: 123} }
|
94
136
|
|
95
|
-
|
96
|
-
|
137
|
+
before do
|
138
|
+
allow(scorekeeper_role).to receive(:resource?).and_return true
|
139
|
+
end
|
97
140
|
|
98
|
-
|
99
|
-
subject.
|
141
|
+
it { expect(subject.allow?(nil, nil, resource)).to be false }
|
142
|
+
it { expect(subject.allow?([scorekeeper_role], "index", resource)).to be true }
|
143
|
+
it { expect(subject.allow?([scorekeeper_role], "edit", resource)).to be false }
|
100
144
|
end
|
101
|
-
|
102
|
-
it_should_behave_like "allow should behave correctly"
|
103
145
|
end
|
104
146
|
end
|
105
147
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,68 +1,70 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rolypoly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Phenow
|
8
|
+
- Jake Waletzko
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2016-12-09 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: bundler
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
16
17
|
requirements:
|
17
|
-
- - ~>
|
18
|
+
- - "~>"
|
18
19
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
20
|
+
version: '1.8'
|
20
21
|
type: :development
|
21
22
|
prerelease: false
|
22
23
|
version_requirements: !ruby/object:Gem::Requirement
|
23
24
|
requirements:
|
24
|
-
- - ~>
|
25
|
+
- - "~>"
|
25
26
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
27
|
+
version: '1.8'
|
27
28
|
- !ruby/object:Gem::Dependency
|
28
29
|
name: rake
|
29
30
|
requirement: !ruby/object:Gem::Requirement
|
30
31
|
requirements:
|
31
|
-
- -
|
32
|
+
- - ">="
|
32
33
|
- !ruby/object:Gem::Version
|
33
34
|
version: '0'
|
34
35
|
type: :development
|
35
36
|
prerelease: false
|
36
37
|
version_requirements: !ruby/object:Gem::Requirement
|
37
38
|
requirements:
|
38
|
-
- -
|
39
|
+
- - ">="
|
39
40
|
- !ruby/object:Gem::Version
|
40
41
|
version: '0'
|
41
42
|
- !ruby/object:Gem::Dependency
|
42
43
|
name: rspec
|
43
44
|
requirement: !ruby/object:Gem::Requirement
|
44
45
|
requirements:
|
45
|
-
- -
|
46
|
+
- - ">="
|
46
47
|
- !ruby/object:Gem::Version
|
47
48
|
version: '0'
|
48
49
|
type: :development
|
49
50
|
prerelease: false
|
50
51
|
version_requirements: !ruby/object:Gem::Requirement
|
51
52
|
requirements:
|
52
|
-
- -
|
53
|
+
- - ">="
|
53
54
|
- !ruby/object:Gem::Version
|
54
55
|
version: '0'
|
55
56
|
description: Tools for handling per-action and per-app Role authorization
|
56
57
|
email:
|
57
58
|
- j.phenow@gmail.com
|
59
|
+
- jnwaletzko@gmail.com
|
58
60
|
executables: []
|
59
61
|
extensions: []
|
60
62
|
extra_rdoc_files: []
|
61
63
|
files:
|
62
|
-
- .gitignore
|
63
|
-
- .rspec
|
64
|
-
- .ruby-gemset
|
65
|
-
- .ruby-version
|
64
|
+
- ".gitignore"
|
65
|
+
- ".rspec"
|
66
|
+
- ".ruby-gemset"
|
67
|
+
- ".ruby-version"
|
66
68
|
- Gemfile
|
67
69
|
- LICENSE.txt
|
68
70
|
- README.md
|
@@ -85,17 +87,17 @@ require_paths:
|
|
85
87
|
- lib
|
86
88
|
required_ruby_version: !ruby/object:Gem::Requirement
|
87
89
|
requirements:
|
88
|
-
- -
|
90
|
+
- - ">="
|
89
91
|
- !ruby/object:Gem::Version
|
90
92
|
version: '0'
|
91
93
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
94
|
requirements:
|
93
|
-
- -
|
95
|
+
- - ">="
|
94
96
|
- !ruby/object:Gem::Version
|
95
97
|
version: '0'
|
96
98
|
requirements: []
|
97
99
|
rubyforge_project:
|
98
|
-
rubygems_version: 2.
|
100
|
+
rubygems_version: 2.4.8
|
99
101
|
signing_key:
|
100
102
|
specification_version: 4
|
101
103
|
summary: Tools for handling per-action and per-app Role authorization
|