cannie 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ec9ec75cbf4049751bdc12e6a3724880a39d729b
4
- data.tar.gz: 0f5750f17a62373de640dfe3765c59bb640778d9
3
+ metadata.gz: 20b0f6d3ffeedaeacc9c4ae11762c861d74b664e
4
+ data.tar.gz: 18f5003cc7ecaabd9e43fbedc23c9350e0e5921e
5
5
  SHA512:
6
- metadata.gz: 083fc7fa69ee1b74fb976edc60be681aea8d1f57e85b8d75d82ca1fa985b775e3f8bfd668d14f7da4dc1bc3b6d4d308579ad14fe24c864f1d589c3266ece6015
7
- data.tar.gz: 92e63adbc1ad697c13bb14c460f4f516a008a8a98748cb8e5b4870d040c52e3fd58420f5a317b7941bb6fe650bb414910b20beeaaf1774073538eddb433048e3
6
+ metadata.gz: cf7e901d46c51c7e698fece777cf9e57c8730e2716fc60f0fb9c518bddcd3814a11905b28b96fec97ead5a26ff48fa7bf64283a6e1cd982213071526fe2f5362
7
+ data.tar.gz: 00e301a82871ea5b5e668cc15b96c43e7af58e97cc45825bfd95e68a1344662bfce97d60b4f22425c33ba0dace67753564b33f7b9fb236e24b6b4ecac51dab09
@@ -37,7 +37,8 @@ module Cannie
37
37
  # @return result of permissions check
38
38
  #
39
39
  def can?(action, on: nil)
40
- rules_for(action, on).all? do |rule|
40
+ rules = rules_for(action, on)
41
+ rules.present? && rules.all? do |rule|
41
42
  rule.permits?(*on)
42
43
  end
43
44
  end
@@ -1,3 +1,3 @@
1
1
  module Cannie
2
- VERSION = "0.0.2"
2
+ VERSION = '0.0.3'
3
3
  end
@@ -46,6 +46,11 @@ describe Cannie::Permissions do
46
46
 
47
47
  let(:permissions) { subject.new }
48
48
 
49
+ it 'returns false if no rules for action exists' do
50
+ permissions.stub(:rules).and_return([])
51
+ expect(permissions.can? :read, on: [2, 4, 8]).to be_false
52
+ end
53
+
49
54
  it 'returns true if all rules for action & subject are permitted' do
50
55
  expect(permissions.can? :read, on: [2, 4, 8]).to be_true
51
56
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cannie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - hck