permiso 0.2.0 → 0.2.1
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.
- data/CHANGELOG.md +4 -0
- data/lib/permiso.rb +1 -1
- data/lib/permiso/version.rb +1 -1
- data/spec/lib/permiso_spec.rb +5 -1
- metadata +1 -1
data/CHANGELOG.md
CHANGED
data/lib/permiso.rb
CHANGED
@@ -27,7 +27,7 @@ module Permiso
|
|
27
27
|
|
28
28
|
def can?(user_roles, action, args={})
|
29
29
|
user_roles = [user_roles] unless user_roles.kind_of? Array
|
30
|
-
return false unless user_roles.detect {|r| role_can?(r, action) }
|
30
|
+
return false unless user_roles.detect {|r| role_can?(r.to_sym, action) }
|
31
31
|
rule_allows?(action)
|
32
32
|
end
|
33
33
|
|
data/lib/permiso/version.rb
CHANGED
data/spec/lib/permiso_spec.rb
CHANGED
@@ -30,12 +30,16 @@ describe Permiso do
|
|
30
30
|
|
31
31
|
it 'should allow, when role is defined' do
|
32
32
|
ability = AbilityTest.new(@booking)
|
33
|
-
p ability
|
34
33
|
ability.can?(:admin, :cancel).should be_true
|
35
34
|
ability.can?(:admin, :create).should be_true
|
36
35
|
ability.can?(:user, :read).should be_true
|
37
36
|
end
|
38
37
|
|
38
|
+
it 'should not make a difference whether role is string or symbol' do
|
39
|
+
ability = AbilityTest.new(@booking)
|
40
|
+
ability.can?('admin', :cancel).should be_true
|
41
|
+
end
|
42
|
+
|
39
43
|
it 'should allow, when there are multiple roles and at least one is allowed' do
|
40
44
|
ability = AbilityTest.new(@booking)
|
41
45
|
ability.can?([:user, :admin], :read).should be_true
|