credentials 2.3.0 → 2.3.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/VERSION +1 -1
- data/credentials.gemspec +2 -2
- data/lib/credentials/rule.rb +4 -4
- data/spec/controllers/test_controller_spec.rb +11 -6
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3.
|
1
|
+
2.3.1
|
data/credentials.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{credentials}
|
8
|
-
s.version = "2.3.
|
8
|
+
s.version = "2.3.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Matt Powell"]
|
12
|
-
s.date = %q{2009-12-
|
12
|
+
s.date = %q{2009-12-17}
|
13
13
|
s.description = %q{A generic actor/resource permission framework based on rules, not objects.}
|
14
14
|
s.email = %q{fauxparse@gmail.com.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/credentials/rule.rb
CHANGED
@@ -55,7 +55,7 @@ module Credentials
|
|
55
55
|
case expected
|
56
56
|
when :self then return false unless actual == args.first
|
57
57
|
when Array then return false unless expected.any? { |item| (item === actual) || (item == :self && actual == args.first) }
|
58
|
-
else return false unless expected === actual
|
58
|
+
else return false unless expected == actual || expected === actual
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -104,13 +104,13 @@ module Credentials
|
|
104
104
|
tr("-", "_").
|
105
105
|
downcase
|
106
106
|
end
|
107
|
-
|
107
|
+
|
108
108
|
if object.respond_to?(:id) && actual.respond_to?(:"#{lclass}_id")
|
109
|
-
return true if actual.send(:"#{lclass}_id") == object.id
|
109
|
+
return true if actual.send(:"#{lclass}_id").to_i == object.id.to_i
|
110
110
|
end
|
111
111
|
|
112
112
|
if actual.respond_to?(:id) && object.respond_to?(:"#{rclass}_id")
|
113
|
-
return true if object.send(:"#{rclass}_id") == actual.id
|
113
|
+
return true if object.send(:"#{rclass}_id").to_i == actual.id.to_i
|
114
114
|
end
|
115
115
|
|
116
116
|
(object.respond_to?(single) && (object.send(single) == actual)) || (object.respond_to?(plural) && (object.send(plural).include?(actual)))
|
@@ -5,7 +5,7 @@ if defined?(ActionController)
|
|
5
5
|
self.current_user_method = :logged_in_user
|
6
6
|
requires_permission_to :view, :stuff, :except => [ :public ]
|
7
7
|
requires_permission_to :break, :stuff, :only => [ :dangerous ]
|
8
|
-
requires_permission_to :create,
|
8
|
+
requires_permission_to :create, Object, :for => :account, :only => [ :create ]
|
9
9
|
|
10
10
|
def index; end
|
11
11
|
def public; end
|
@@ -21,13 +21,15 @@ if defined?(ActionController)
|
|
21
21
|
credentials do |user|
|
22
22
|
user.can :view, :stuff
|
23
23
|
user.can :break, :stuff, :if => :special?
|
24
|
-
user.can :create,
|
24
|
+
user.can :create, Object, :for => :account
|
25
25
|
|
26
|
-
|
26
|
+
attr_accessor :test_account_id
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
class TestAccount
|
30
|
+
class TestAccount
|
31
|
+
attr_accessor :id
|
32
|
+
end
|
31
33
|
|
32
34
|
describe TestController do
|
33
35
|
it "should know how to specify access credentials" do
|
@@ -87,7 +89,8 @@ if defined?(ActionController)
|
|
87
89
|
|
88
90
|
it "should be able to do stuff on its own account" do
|
89
91
|
@my_account = TestAccount.new
|
90
|
-
@
|
92
|
+
@my_account.id = 5
|
93
|
+
@user.stub!(:test_account_id).and_return(@my_account.id)
|
91
94
|
controller.stub!(:account).and_return(@my_account)
|
92
95
|
lambda {
|
93
96
|
get :create
|
@@ -98,7 +101,9 @@ if defined?(ActionController)
|
|
98
101
|
it "should not be able to do stuff on someone else's account" do
|
99
102
|
@my_account = TestAccount.new
|
100
103
|
@your_account = TestAccount.new
|
101
|
-
@
|
104
|
+
@my_account.id = 5
|
105
|
+
@your_account.id = 6
|
106
|
+
@user.stub!(:test_account_id).and_return(@my_account.id)
|
102
107
|
controller.stub!(:account).and_return(@your_account)
|
103
108
|
lambda {
|
104
109
|
get :create
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: credentials
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Powell
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-12-
|
12
|
+
date: 2009-12-17 00:00:00 +13:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|