pundit-matchers 1.4.0 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pundit/matchers.rb +9 -15
- 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: 75eb6737bf97672c843b34798c76b2166c066224
|
4
|
+
data.tar.gz: d2a0041a8e59749948b8d3550e73532cca186baa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46b092d9f548f9a8c48c622fd70e7c78f4aec1f0e09956dcd06c1031fea94158e103fef923d090bd24a76020881bddd868cebe708e2cf27facd0e70ec49cb514
|
7
|
+
data.tar.gz: 4af2e2282a5bd8a65122a5c9b44b1befaba373e33fe5a3830aeebe9588d29cb253a243a2ec846bcbebf0e95ae1cabdaeb22be66409161c3214fcb5428f12837f
|
data/lib/pundit/matchers.rb
CHANGED
@@ -25,7 +25,7 @@ module Pundit
|
|
25
25
|
|
26
26
|
RSpec::Matchers.define :forbid_actions do |actions|
|
27
27
|
match do |policy|
|
28
|
-
return false if actions.count <
|
28
|
+
return false if actions.count < 1
|
29
29
|
@allowed_actions = actions.select do |action|
|
30
30
|
policy.public_send("#{action}?")
|
31
31
|
end
|
@@ -34,12 +34,11 @@ module Pundit
|
|
34
34
|
|
35
35
|
attr_reader :allowed_actions
|
36
36
|
|
37
|
-
zero_actions_failure_message = 'At least
|
37
|
+
zero_actions_failure_message = 'At least one action must be ' \
|
38
38
|
'specified when using the forbid_actions matcher.'
|
39
39
|
|
40
40
|
failure_message do |policy|
|
41
|
-
|
42
|
-
when 0
|
41
|
+
if actions.count == 0
|
43
42
|
zero_actions_failure_message
|
44
43
|
else
|
45
44
|
"#{policy.class} expected to forbid #{actions}, but allowed " \
|
@@ -48,8 +47,7 @@ module Pundit
|
|
48
47
|
end
|
49
48
|
|
50
49
|
failure_message_when_negated do |policy|
|
51
|
-
|
52
|
-
when 0
|
50
|
+
if actions.count == 0
|
53
51
|
zero_actions_failure_message
|
54
52
|
else
|
55
53
|
"#{policy.class} expected to permit #{actions}, but forbade " \
|
@@ -148,7 +146,7 @@ module Pundit
|
|
148
146
|
|
149
147
|
RSpec::Matchers.define :permit_actions do |actions|
|
150
148
|
match do |policy|
|
151
|
-
return false if actions.count <
|
149
|
+
return false if actions.count < 1
|
152
150
|
@forbidden_actions = actions.reject do |action|
|
153
151
|
policy.public_send("#{action}?")
|
154
152
|
end
|
@@ -157,12 +155,11 @@ module Pundit
|
|
157
155
|
|
158
156
|
attr_reader :forbidden_actions
|
159
157
|
|
160
|
-
zero_actions_failure_message = 'At least
|
161
|
-
'
|
158
|
+
zero_actions_failure_message = 'At least one action must be specified ' \
|
159
|
+
'when using the permit_actions matcher.'
|
162
160
|
|
163
161
|
failure_message do |policy|
|
164
|
-
|
165
|
-
when 0
|
162
|
+
if actions.count == 0
|
166
163
|
zero_actions_failure_message
|
167
164
|
else
|
168
165
|
"#{policy.class} expected to permit #{actions}, but forbade " \
|
@@ -171,11 +168,8 @@ module Pundit
|
|
171
168
|
end
|
172
169
|
|
173
170
|
failure_message_when_negated do |policy|
|
174
|
-
|
175
|
-
when 0
|
171
|
+
if actions.count == 0
|
176
172
|
zero_actions_failure_message
|
177
|
-
when 1
|
178
|
-
one_action_failure_message
|
179
173
|
else
|
180
174
|
"#{policy.class} expected to forbid #{actions}, but allowed " \
|
181
175
|
"#{forbidden_actions} for #{policy.user.inspect}."
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pundit-matchers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Alley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pundit
|