moat 0.4 → 0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -3
- data/lib/moat/rspec.rb +6 -2
- data/lib/moat/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27fe35c24015fbbda8f21da12a438c55e96fe64f
|
4
|
+
data.tar.gz: f0b05ea91ff3a9281fa6dd0527b94a067c3ed088
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8f8feb0e33f5e3851d564b125c5e5eb764995993efc0b9d474e8558485adcf9990ab2da1f420dd158ad01a83d70859c2f0932ad0c0869ee8cb6fdf63e86dd76
|
7
|
+
data.tar.gz: 98d4481b9be0e0629de4243fcc8cf87c07e79f9950b682c44b5ba4dd13c9f226f9de8d9dc7dfdd1a14fafd1071da66930ffc5b2bb7f2a73369c9cb76226f65e7
|
data/README.md
CHANGED
@@ -323,14 +323,16 @@ describe ThingPolicy do
|
|
323
323
|
end
|
324
324
|
```
|
325
325
|
|
326
|
-
If a non-standard scope is required for filters, it can be overridden. It
|
327
|
-
defaults to the `all` relation for ActiveRecord models or a simple Array
|
328
|
-
otherwise.
|
326
|
+
If a non-standard scope is required for filters, it can be overridden. It defaults to the `all` relation for ActiveRecord models or a simple Array otherwise.
|
329
327
|
|
330
328
|
```ruby
|
331
329
|
scope { resource.container }
|
332
330
|
```
|
333
331
|
|
332
|
+
The current role can be referenced with `current_role`, or `role` for just the role name as a symbol.
|
333
|
+
|
334
|
+
When using `context` or `description` in combination with `roles`, we recommend that `roles` be the outermost nesting level. We've found that most of the time it's easier to maintain in the long term.
|
335
|
+
|
334
336
|
## Ensure all policies have full test coverage
|
335
337
|
|
336
338
|
```ruby
|
data/lib/moat/rspec.rb
CHANGED
@@ -130,15 +130,19 @@ module Moat
|
|
130
130
|
::RSpec.current_example.metadata.fetch(:role)
|
131
131
|
end
|
132
132
|
|
133
|
+
def current_role
|
134
|
+
public_send(role)
|
135
|
+
end
|
136
|
+
|
133
137
|
def permitted_authorizations(policy_class)
|
134
|
-
policy_instance = policy_class::Authorization.new(
|
138
|
+
policy_instance = policy_class::Authorization.new(current_role, policy_example_resource)
|
135
139
|
policy_authorizations.select do |authorization|
|
136
140
|
policy_instance.public_send(authorization)
|
137
141
|
end
|
138
142
|
end
|
139
143
|
|
140
144
|
def permitted_through_filters(policy_class)
|
141
|
-
policy_instance = policy_class::Filter.new(
|
145
|
+
policy_instance = policy_class::Filter.new(current_role, policy_example_scope)
|
142
146
|
policy_filters.select do |filter|
|
143
147
|
policy_instance.public_send(filter).include?(policy_example_resource)
|
144
148
|
end
|
data/lib/moat/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.5'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Poll Everywhere
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|