moat 0.2 → 0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/moat.rb +0 -2
- data/lib/moat/version.rb +1 -1
- data/spec/moat_spec.rb +10 -27
- 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: 8e7f85e51dd0ffe82fe3b6437e93e4ada13459be
|
4
|
+
data.tar.gz: dccbce2a4b6ceece7d32391d7e4fd6c4b8440ec3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b48428d4a14e1917564a1e89ed089376a7b2cdfcaaa8167f498372f824078a58c286c08e5d396e4a48c9e38fa575a3c0dd7e3f11098de541446cc3244736f43e
|
7
|
+
data.tar.gz: 4951f823e10c5d9d9986d6c863296c6502a7fb1cc4cdd9d19287d4354e681da5ef30de49c495e5d23aec28c86d7124e26de0ce8042f04689ffd8857810f63ffa
|
data/Gemfile.lock
CHANGED
data/lib/moat.rb
CHANGED
data/lib/moat/version.rb
CHANGED
data/spec/moat_spec.rb
CHANGED
@@ -113,24 +113,25 @@ describe Moat do
|
|
113
113
|
end
|
114
114
|
|
115
115
|
it "fails if a corresponding action can't be found" do
|
116
|
-
expect { moat_consumer.policy_filter([1, 2, 3], :invalid_action) }.
|
116
|
+
expect { moat_consumer.policy_filter([1, 2, 3], :invalid_action, policy: IntegerPolicy) }.
|
117
117
|
to raise_error(Moat::ActionNotFoundError, "IntegerPolicy::Filter#invalid_action")
|
118
118
|
end
|
119
119
|
|
120
120
|
it "returns the value of applying a policy scope filter to the original scope" do
|
121
|
-
expect(moat_consumer.policy_filter([1, 2, 3, 4, 5])).to eql([2, 4])
|
121
|
+
expect(moat_consumer.policy_filter([1, 2, 3, 4, 5], policy: IntegerPolicy)).to eql([2, 4])
|
122
122
|
end
|
123
123
|
|
124
124
|
it "uses specified action" do
|
125
|
-
expect(moat_consumer.policy_filter([2, 3], :show)).to eql([3])
|
125
|
+
expect(moat_consumer.policy_filter([2, 3], :show, policy: IntegerPolicy)).to eql([3])
|
126
126
|
end
|
127
127
|
|
128
128
|
it "uses specified policy" do
|
129
|
-
expect(moat_consumer.policy_filter([2, 3], policy: OtherIntegerPolicy)).
|
129
|
+
expect(moat_consumer.policy_filter([2, 3], policy: OtherIntegerPolicy)).
|
130
|
+
to eql([3])
|
130
131
|
end
|
131
132
|
|
132
133
|
it "uses specified user" do
|
133
|
-
expect(moat_consumer.policy_filter([2, 3], user: "specified user")).to eql([2, 3])
|
134
|
+
expect(moat_consumer.policy_filter([2, 3], user: "specified user", policy: IntegerPolicy)).to eql([2, 3])
|
134
135
|
end
|
135
136
|
end
|
136
137
|
|
@@ -148,7 +149,7 @@ describe Moat do
|
|
148
149
|
end
|
149
150
|
|
150
151
|
it "fails if a corresponding action can't be found" do
|
151
|
-
expect { moat_consumer.authorize([1, 2, 3], :invalid_action
|
152
|
+
expect { moat_consumer.authorize([1, 2, 3], :invalid_action?, policy: IntegerPolicy) }.
|
152
153
|
to raise_error(Moat::ActionNotFoundError, "IntegerPolicy::Authorization#invalid_action?")
|
153
154
|
end
|
154
155
|
|
@@ -183,7 +184,7 @@ describe Moat do
|
|
183
184
|
end
|
184
185
|
context "policy_filter called" do
|
185
186
|
it "does not raise an exception" do
|
186
|
-
moat_consumer.policy_filter([1, 2])
|
187
|
+
moat_consumer.policy_filter([1, 2], policy: IntegerPolicy)
|
187
188
|
expect { moat_consumer.verify_policy_applied }.not_to raise_error
|
188
189
|
end
|
189
190
|
end
|
@@ -280,7 +281,7 @@ describe Moat do
|
|
280
281
|
end
|
281
282
|
|
282
283
|
it "infers a policy from an object's `model` method" do
|
283
|
-
class
|
284
|
+
class DefinesModelName
|
284
285
|
def self.model
|
285
286
|
Fake
|
286
287
|
end
|
@@ -289,25 +290,7 @@ describe Moat do
|
|
289
290
|
[11, 12]
|
290
291
|
end
|
291
292
|
end
|
292
|
-
expect(moat_consumer.policy_filter(
|
293
|
-
end
|
294
|
-
|
295
|
-
it "infers a policy from when scope is a non-Array that implements to_ary" do
|
296
|
-
class IntContainer
|
297
|
-
def initialize(*numbers)
|
298
|
-
@numbers = numbers
|
299
|
-
end
|
300
|
-
|
301
|
-
def to_ary
|
302
|
-
@numbers
|
303
|
-
end
|
304
|
-
|
305
|
-
def select
|
306
|
-
@numbers.select { |n| yield(n) }
|
307
|
-
end
|
308
|
-
end
|
309
|
-
|
310
|
-
expect(moat_consumer.policy_filter(IntContainer.new(1, 2, 3, 4, 5))).to eql([2, 4])
|
293
|
+
expect(moat_consumer.policy_filter(DefinesModelName)).to eql([11, 12])
|
311
294
|
end
|
312
295
|
end
|
313
296
|
end
|
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.3'
|
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-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|