rolify 3.1.0 → 3.2.0
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/.gitignore +2 -1
- data/.travis.yml +2 -4
- data/CHANGELOG.rdoc +20 -0
- data/README.md +42 -6
- data/lib/generators/rolify/role/role_generator.rb +11 -3
- data/lib/generators/rolify/role/templates/initializer.rb +2 -1
- data/lib/generators/rolify/role/templates/role-active_record.rb +2 -0
- data/lib/generators/rolify/role/templates/role-mongoid.rb +11 -9
- data/lib/rolify/adapters/active_record/resource_adapter.rb +12 -4
- data/lib/rolify/adapters/active_record/role_adapter.rb +11 -4
- data/lib/rolify/adapters/active_record/scopes.rb +27 -0
- data/lib/rolify/adapters/base.rb +5 -0
- data/lib/rolify/adapters/mongoid/resource_adapter.rb +9 -5
- data/lib/rolify/adapters/mongoid/role_adapter.rb +14 -2
- data/lib/rolify/adapters/mongoid/scopes.rb +27 -0
- data/lib/rolify/finders.rb +39 -0
- data/lib/rolify/railtie.rb +1 -1
- data/lib/rolify/resource.rb +2 -1
- data/lib/rolify/role.rb +17 -2
- data/lib/rolify/version.rb +1 -1
- data/lib/rolify.rb +14 -5
- data/rolify.gemspec +7 -5
- data/spec/generators/rolify/role/role_generator_spec.rb +17 -61
- data/spec/rolify/custom_spec.rb +12 -0
- data/spec/rolify/resource_spec.rb +65 -17
- data/spec/rolify/role_spec.rb +12 -0
- data/spec/rolify/shared_contexts.rb +12 -0
- data/spec/rolify/shared_examples/shared_examples_for_callbacks.rb +57 -0
- data/spec/rolify/shared_examples/shared_examples_for_finders.rb +77 -0
- data/spec/rolify/shared_examples/shared_examples_for_only_has_role.rb +174 -0
- data/spec/rolify/shared_examples/shared_examples_for_roles.rb +47 -25
- data/spec/rolify/shared_examples/shared_examples_for_scopes.rb +38 -0
- data/spec/spec_helper.rb +13 -0
- data/spec/support/adapters/active_record.rb +5 -0
- data/spec/support/adapters/mongoid.rb +26 -2
- data/spec/support/adapters/mongoid.yml +6 -0
- metadata +63 -27
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
shared_examples_for "#only_has_role?_examples" do |param_name, param_method|
|
|
2
|
+
context "using #{param_name} as parameter" do
|
|
3
|
+
context "with a global role", :scope => :global do
|
|
4
|
+
subject do
|
|
5
|
+
user = User.create(:login => "global_user")
|
|
6
|
+
user.add_role "global_role".send(param_method)
|
|
7
|
+
user
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it { subject.only_has_role?("global_role".send(param_method)).should be_true }
|
|
11
|
+
|
|
12
|
+
context "on resource request" do
|
|
13
|
+
it { subject.only_has_role?("global_role".send(param_method), Forum.first).should be_true }
|
|
14
|
+
it { subject.only_has_role?("global_role".send(param_method), Forum).should be_true }
|
|
15
|
+
it { subject.only_has_role?("global_role".send(param_method), :any).should be_true }
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
context "with another global role" do
|
|
19
|
+
before(:all) { role_class.create(:name => "another_global_role") }
|
|
20
|
+
|
|
21
|
+
it { subject.only_has_role?("another_global_role".send(param_method)).should be_false }
|
|
22
|
+
it { subject.only_has_role?("another_global_role".send(param_method), :any).should be_false }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "should not get an instance scoped role" do
|
|
26
|
+
subject.only_has_role?("moderator".send(param_method), Group.first).should be_false
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "should not get a class scoped role" do
|
|
30
|
+
subject.only_has_role?("manager".send(param_method), Forum).should be_false
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
context "using inexisting role" do
|
|
34
|
+
it { subject.only_has_role?("dummy".send(param_method)).should be_false }
|
|
35
|
+
it { subject.only_has_role?("dumber".send(param_method), Forum.first).should be_false }
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
context "with multiple roles" do
|
|
39
|
+
before(:all) { subject.add_role "multiple_global_roles".send(param_method) }
|
|
40
|
+
|
|
41
|
+
it { subject.only_has_role?("global_role".send(param_method)).should be_false }
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
context "with a class scoped role", :scope => :class do
|
|
46
|
+
subject do
|
|
47
|
+
user = User.create(:login => "class_user")
|
|
48
|
+
user.add_role "class_role".send(param_method), Forum
|
|
49
|
+
user
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
context "on class scoped role request" do
|
|
53
|
+
it { subject.only_has_role?("class_role".send(param_method), Forum).should be_true }
|
|
54
|
+
it { subject.only_has_role?("class_role".send(param_method), Forum.first).should be_true }
|
|
55
|
+
it { subject.only_has_role?("class_role".send(param_method), :any).should be_true }
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "should not get a scoped role when asking for a global" do
|
|
59
|
+
subject.only_has_role?("class_role".send(param_method)).should be_false
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "should not get a global role" do
|
|
63
|
+
role_class.create(:name => "global_role")
|
|
64
|
+
subject.only_has_role?("global_role".send(param_method)).should be_false
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
context "with another class scoped role" do
|
|
68
|
+
context "on the same resource but with a different name" do
|
|
69
|
+
before(:all) { role_class.create(:name => "another_class_role", :resource_type => "Forum") }
|
|
70
|
+
|
|
71
|
+
it { subject.only_has_role?("another_class_role".send(param_method), Forum).should be_false }
|
|
72
|
+
it { subject.only_has_role?("another_class_role".send(param_method), :any).should be_false }
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
context "on another resource with the same name" do
|
|
76
|
+
before(:all) { role_class.create(:name => "class_role", :resource_type => "Group") }
|
|
77
|
+
|
|
78
|
+
it { subject.only_has_role?("class_role".send(param_method), Group).should be_false }
|
|
79
|
+
it { subject.only_has_role?("class_role".send(param_method), :any).should be_true }
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
context "on another resource with another name" do
|
|
83
|
+
before(:all) { role_class.create(:name => "another_class_role", :resource_type => "Group") }
|
|
84
|
+
|
|
85
|
+
it { subject.only_has_role?("another_class_role".send(param_method), Group).should be_false }
|
|
86
|
+
it { subject.only_has_role?("another_class_role".send(param_method), :any).should be_false }
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
context "using inexisting role" do
|
|
91
|
+
it { subject.only_has_role?("dummy".send(param_method), Forum).should be_false }
|
|
92
|
+
it { subject.only_has_role?("dumber".send(param_method)).should be_false }
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
context "with multiple roles" do
|
|
96
|
+
before(:all) { subject.add_role "multiple_class_roles".send(param_method) }
|
|
97
|
+
|
|
98
|
+
it { subject.only_has_role?("class_role".send(param_method), Forum).should be_false }
|
|
99
|
+
it { subject.only_has_role?("class_role".send(param_method), Forum.first).should be_false }
|
|
100
|
+
it { subject.only_has_role?("class_role".send(param_method), :any).should be_false }
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
context "with a instance scoped role", :scope => :instance do
|
|
105
|
+
subject do
|
|
106
|
+
user = User.create(:login => "instance_user")
|
|
107
|
+
user.add_role "instance_role".send(param_method), Forum.first
|
|
108
|
+
user
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
context "on instance scoped role request" do
|
|
112
|
+
it { subject.only_has_role?("instance_role".send(param_method), Forum.first).should be_true }
|
|
113
|
+
it { subject.only_has_role?("instance_role".send(param_method), :any).should be_true }
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
it "should not get an instance scoped role when asking for a global" do
|
|
117
|
+
subject.only_has_role?("instance_role".send(param_method)).should be_false
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
it "should not get an instance scoped role when asking for a class scoped" do
|
|
121
|
+
subject.only_has_role?("instance_role".send(param_method), Forum).should be_false
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
it "should not get a global role" do
|
|
125
|
+
role_class.create(:name => "global_role")
|
|
126
|
+
subject.only_has_role?("global_role".send(param_method)).should be_false
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
context "with another instance scoped role" do
|
|
130
|
+
context "on the same resource but with a different role name" do
|
|
131
|
+
before(:all) { role_class.create(:name => "another_instance_role", :resource => Forum.first) }
|
|
132
|
+
|
|
133
|
+
it { subject.only_has_role?("another_instance_role".send(param_method), Forum.first).should be_false }
|
|
134
|
+
it { subject.only_has_role?("another_instance_role".send(param_method), :any).should be_false }
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
context "on another resource of the same type but with the same role name" do
|
|
138
|
+
before(:all) { role_class.create(:name => "moderator", :resource => Forum.last) }
|
|
139
|
+
|
|
140
|
+
it { subject.only_has_role?("instance_role".send(param_method), Forum.last).should be_false }
|
|
141
|
+
it { subject.only_has_role?("instance_role".send(param_method), :any).should be_true }
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
context "on another resource of different type but with the same role name" do
|
|
145
|
+
before(:all) { role_class.create(:name => "moderator", :resource => Group.last) }
|
|
146
|
+
|
|
147
|
+
it { subject.only_has_role?("instance_role".send(param_method), Group.last).should be_false }
|
|
148
|
+
it { subject.only_has_role?("instance_role".send(param_method), :any).should be_true }
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
context "on another resource of the same type and with another role name" do
|
|
152
|
+
before(:all) { role_class.create(:name => "another_instance_role", :resource => Forum.last) }
|
|
153
|
+
|
|
154
|
+
it { subject.only_has_role?("another_instance_role".send(param_method), Forum.last).should be_false }
|
|
155
|
+
it { subject.only_has_role?("another_instance_role".send(param_method), :any).should be_false }
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
context "on another resource of different type and with another role name" do
|
|
159
|
+
before(:all) { role_class.create(:name => "another_instance_role", :resource => Group.first) }
|
|
160
|
+
|
|
161
|
+
it { subject.only_has_role?("another_instance_role".send(param_method), Group.first).should be_false }
|
|
162
|
+
it { subject.only_has_role?("another_instance_role".send(param_method), :any).should be_false }
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
context "with multiple roles" do
|
|
167
|
+
before(:all) { subject.add_role "multiple_instance_roles".send(param_method), Forum.first }
|
|
168
|
+
|
|
169
|
+
it { subject.only_has_role?("instance_role".send(param_method), Forum.first).should be_false }
|
|
170
|
+
it { subject.only_has_role?("instance_role".send(param_method), :any).should be_false }
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
end
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
require "rolify/shared_contexts"
|
|
2
2
|
require "rolify/shared_examples/shared_examples_for_add_role"
|
|
3
3
|
require "rolify/shared_examples/shared_examples_for_has_role"
|
|
4
|
+
require "rolify/shared_examples/shared_examples_for_only_has_role"
|
|
4
5
|
require "rolify/shared_examples/shared_examples_for_has_all_roles"
|
|
5
6
|
require "rolify/shared_examples/shared_examples_for_has_any_role"
|
|
6
7
|
require "rolify/shared_examples/shared_examples_for_remove_role"
|
|
7
|
-
|
|
8
|
+
require "rolify/shared_examples/shared_examples_for_finders"
|
|
8
9
|
|
|
9
10
|
shared_examples_for Rolify::Role do
|
|
10
11
|
before(:all) do
|
|
@@ -16,17 +17,14 @@ shared_examples_for Rolify::Role do
|
|
|
16
17
|
Group.resourcify :role_cname => role_class.to_s
|
|
17
18
|
end
|
|
18
19
|
|
|
19
|
-
context "in
|
|
20
|
+
context "in the Instance level " do
|
|
20
21
|
before(:all) do
|
|
21
22
|
admin = user_class.first
|
|
22
23
|
admin.add_role :admin
|
|
23
24
|
admin.add_role :moderator, Forum.first
|
|
24
|
-
admin
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
subject
|
|
28
|
-
user_class.first
|
|
29
|
-
end
|
|
27
|
+
subject { user_class.first }
|
|
30
28
|
|
|
31
29
|
[ :has_role, :grant, :add_role ].each do |method_alias|
|
|
32
30
|
it { should respond_to(method_alias.to_sym).with(1).arguments }
|
|
@@ -49,30 +47,54 @@ shared_examples_for Rolify::Role do
|
|
|
49
47
|
|
|
50
48
|
it { should_not respond_to(:is_admin?) }
|
|
51
49
|
it { should_not respond_to(:is_moderator_of?) }
|
|
52
|
-
|
|
50
|
+
|
|
51
|
+
describe "#has_role" do
|
|
52
|
+
it_should_behave_like "#add_role_examples", "String", :to_s
|
|
53
|
+
it_should_behave_like "#add_role_examples", "Symbol", :to_sym
|
|
54
|
+
end
|
|
53
55
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
describe "#has_role?" do
|
|
57
|
+
it_should_behave_like "#has_role?_examples", "String", :to_s
|
|
58
|
+
it_should_behave_like "#has_role?_examples", "Symbol", :to_sym
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
describe "#only_has_role?" do
|
|
62
|
+
it_should_behave_like "#only_has_role?_examples", "String", :to_s
|
|
63
|
+
it_should_behave_like "#only_has_role?_examples", "Symbol", :to_sym
|
|
64
|
+
end
|
|
58
65
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
66
|
+
describe "#has_all_roles?" do
|
|
67
|
+
it_should_behave_like "#has_all_roles?_examples", "String", :to_s
|
|
68
|
+
it_should_behave_like "#has_all_roles?_examples", "Symbol", :to_sym
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
describe "#has_any_role?" do
|
|
72
|
+
it_should_behave_like "#has_any_role?_examples", "String", :to_s
|
|
73
|
+
it_should_behave_like "#has_any_role?_examples", "Symbol", :to_sym
|
|
74
|
+
end
|
|
63
75
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
76
|
+
describe "#has_no_role" do
|
|
77
|
+
it_should_behave_like "#remove_role_examples", "String", :to_s
|
|
78
|
+
it_should_behave_like "#remove_role_examples", "Symbol", :to_sym
|
|
79
|
+
end
|
|
67
80
|
end
|
|
68
81
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
82
|
+
context "with a new instance" do
|
|
83
|
+
let(:user) { user_class.new }
|
|
84
|
+
|
|
85
|
+
before(:all) do
|
|
86
|
+
user.add_role :admin
|
|
87
|
+
user.add_role :moderator, Forum.first
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
subject { user }
|
|
91
|
+
|
|
92
|
+
it { should have_role :admin }
|
|
93
|
+
it { should have_role :moderator, Forum.first }
|
|
94
|
+
end
|
|
73
95
|
|
|
74
|
-
|
|
75
|
-
it_should_behave_like
|
|
76
|
-
it_should_behave_like
|
|
96
|
+
context "on the Class level ", :scope => :mixed do
|
|
97
|
+
it_should_behave_like :finders, "String", :to_s
|
|
98
|
+
it_should_behave_like :finders, "Symbol", :to_sym
|
|
77
99
|
end
|
|
78
100
|
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require "rolify/shared_contexts"
|
|
2
|
+
|
|
3
|
+
shared_examples_for "Role.scopes" do |param_name, param_method|
|
|
4
|
+
before(:all) do
|
|
5
|
+
role_class.destroy_all
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
subject { user_class.first }
|
|
9
|
+
|
|
10
|
+
describe ".global" do
|
|
11
|
+
let!(:admin_role) { subject.add_role :admin }
|
|
12
|
+
let!(:staff_role) { subject.add_role :staff }
|
|
13
|
+
|
|
14
|
+
it { subject.roles.global.should == [ admin_role, staff_role ] }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe ".class_scoped" do
|
|
18
|
+
let!(:manager_role) { subject.add_role :manager, Group }
|
|
19
|
+
let!(:moderator_role) { subject.add_role :moderator, Forum }
|
|
20
|
+
|
|
21
|
+
it { subject.roles.class_scoped.should == [ manager_role, moderator_role ] }
|
|
22
|
+
it { subject.roles.class_scoped(Group).should == [ manager_role ] }
|
|
23
|
+
it { subject.roles.class_scoped(Forum).should == [ moderator_role ] }
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
describe ".instance_scoped" do
|
|
27
|
+
let!(:visitor_role) { subject.add_role :visitor, Forum.first }
|
|
28
|
+
let!(:zombie_role) { subject.add_role :visitor, Forum.last }
|
|
29
|
+
let!(:anonymous_role) { subject.add_role :anonymous, Group.last }
|
|
30
|
+
|
|
31
|
+
it { subject.roles.instance_scoped.should == [ visitor_role, zombie_role, anonymous_role ] }
|
|
32
|
+
it { subject.roles.instance_scoped(Forum).should == [ visitor_role, zombie_role ] }
|
|
33
|
+
it { subject.roles.instance_scoped(Forum.first).should == [ visitor_role ] }
|
|
34
|
+
it { subject.roles.instance_scoped(Forum.last).should == [ zombie_role ] }
|
|
35
|
+
it { subject.roles.instance_scoped(Group.last).should == [ anonymous_role ] }
|
|
36
|
+
it { subject.roles.instance_scoped(Group.first).should be_empty }
|
|
37
|
+
end
|
|
38
|
+
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
require 'rubygems'
|
|
2
|
+
require "bundler/setup"
|
|
3
|
+
|
|
2
4
|
require 'rolify'
|
|
3
5
|
require 'ammeter/init'
|
|
4
6
|
|
|
@@ -10,4 +12,15 @@ load File.dirname(__FILE__) + '/support/data.rb'
|
|
|
10
12
|
def reset_defaults
|
|
11
13
|
Rolify.use_defaults
|
|
12
14
|
Rolify.use_mongoid if ENV['ADAPTER'] == "mongoid"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def provision_user(user, roles)
|
|
18
|
+
roles.each do |role|
|
|
19
|
+
if role.is_a? Array
|
|
20
|
+
user.add_role *role
|
|
21
|
+
else
|
|
22
|
+
user.add_role role
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
user
|
|
13
26
|
end
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require 'active_record'
|
|
2
2
|
|
|
3
|
+
RSpec::Matchers::OperatorMatcher.register(ActiveRecord::Relation, '=~', RSpec::Matchers::BuiltIn::MatchArray)
|
|
3
4
|
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
|
|
4
5
|
ActiveRecord::Base.extend Rolify
|
|
5
6
|
|
|
@@ -13,6 +14,8 @@ end
|
|
|
13
14
|
class Role < ActiveRecord::Base
|
|
14
15
|
has_and_belongs_to_many :users, :join_table => :users_roles
|
|
15
16
|
belongs_to :resource, :polymorphic => true
|
|
17
|
+
|
|
18
|
+
extend Rolify::Adapter::Scopes
|
|
16
19
|
end
|
|
17
20
|
|
|
18
21
|
class Forum < ActiveRecord::Base
|
|
@@ -30,4 +33,6 @@ end
|
|
|
30
33
|
class Privilege < ActiveRecord::Base
|
|
31
34
|
has_and_belongs_to_many :customers, :join_table => :customers_privileges
|
|
32
35
|
belongs_to :resource, :polymorphic => true
|
|
36
|
+
|
|
37
|
+
extend Rolify::Adapter::Scopes
|
|
33
38
|
end
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
require 'mongoid'
|
|
2
2
|
|
|
3
|
-
Mongoid.
|
|
4
|
-
|
|
3
|
+
Mongoid.load!("spec/support/adapters/mongoid.yml", :test)
|
|
4
|
+
|
|
5
|
+
RSpec.configure do |config|
|
|
6
|
+
config.include Mongoid::Matchers
|
|
5
7
|
end
|
|
6
8
|
|
|
7
9
|
::Mongoid::Document.module_eval do
|
|
@@ -26,6 +28,17 @@ class Role
|
|
|
26
28
|
belongs_to :resource, :polymorphic => true
|
|
27
29
|
|
|
28
30
|
field :name, :type => String
|
|
31
|
+
index({ :name => 1 }, { :unique => true })
|
|
32
|
+
index(
|
|
33
|
+
{
|
|
34
|
+
:name => 1,
|
|
35
|
+
:resource_type => 1,
|
|
36
|
+
:resource_id => 1
|
|
37
|
+
},
|
|
38
|
+
{ :unique => true }
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
scopify
|
|
29
42
|
end
|
|
30
43
|
|
|
31
44
|
class Forum
|
|
@@ -55,4 +68,15 @@ class Privilege
|
|
|
55
68
|
belongs_to :resource, :polymorphic => true
|
|
56
69
|
|
|
57
70
|
field :name, :type => String
|
|
71
|
+
index({ :name => 1 }, { :unique => true })
|
|
72
|
+
index(
|
|
73
|
+
{
|
|
74
|
+
:name => 1,
|
|
75
|
+
:resource_type => 1,
|
|
76
|
+
:resource_id => 1
|
|
77
|
+
},
|
|
78
|
+
{ :unique => true }
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
scopify
|
|
58
82
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rolify
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.2.0
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,11 +9,11 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2012-
|
|
12
|
+
date: 2012-08-08 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: sqlite3
|
|
16
|
-
requirement: &
|
|
16
|
+
requirement: &70098036310660 !ruby/object:Gem::Requirement
|
|
17
17
|
none: false
|
|
18
18
|
requirements:
|
|
19
19
|
- - ! '>='
|
|
@@ -21,43 +21,43 @@ dependencies:
|
|
|
21
21
|
version: '0'
|
|
22
22
|
type: :development
|
|
23
23
|
prerelease: false
|
|
24
|
-
version_requirements: *
|
|
24
|
+
version_requirements: *70098036310660
|
|
25
25
|
- !ruby/object:Gem::Dependency
|
|
26
|
-
name:
|
|
27
|
-
requirement: &
|
|
26
|
+
name: bson_ext
|
|
27
|
+
requirement: &70098036309620 !ruby/object:Gem::Requirement
|
|
28
28
|
none: false
|
|
29
29
|
requirements:
|
|
30
30
|
- - ! '>='
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version:
|
|
32
|
+
version: '0'
|
|
33
33
|
type: :development
|
|
34
34
|
prerelease: false
|
|
35
|
-
version_requirements: *
|
|
35
|
+
version_requirements: *70098036309620
|
|
36
36
|
- !ruby/object:Gem::Dependency
|
|
37
|
-
name:
|
|
38
|
-
requirement: &
|
|
37
|
+
name: activerecord
|
|
38
|
+
requirement: &70098036308480 !ruby/object:Gem::Requirement
|
|
39
39
|
none: false
|
|
40
40
|
requirements:
|
|
41
41
|
- - ! '>='
|
|
42
42
|
- !ruby/object:Gem::Version
|
|
43
|
-
version:
|
|
43
|
+
version: 3.1.0
|
|
44
44
|
type: :development
|
|
45
45
|
prerelease: false
|
|
46
|
-
version_requirements: *
|
|
46
|
+
version_requirements: *70098036308480
|
|
47
47
|
- !ruby/object:Gem::Dependency
|
|
48
|
-
name:
|
|
49
|
-
requirement: &
|
|
48
|
+
name: mongoid
|
|
49
|
+
requirement: &70098036307720 !ruby/object:Gem::Requirement
|
|
50
50
|
none: false
|
|
51
51
|
requirements:
|
|
52
52
|
- - ! '>='
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '0'
|
|
54
|
+
version: '3.0'
|
|
55
55
|
type: :development
|
|
56
56
|
prerelease: false
|
|
57
|
-
version_requirements: *
|
|
57
|
+
version_requirements: *70098036307720
|
|
58
58
|
- !ruby/object:Gem::Dependency
|
|
59
59
|
name: ammeter
|
|
60
|
-
requirement: &
|
|
60
|
+
requirement: &70098036307200 !ruby/object:Gem::Requirement
|
|
61
61
|
none: false
|
|
62
62
|
requirements:
|
|
63
63
|
- - ! '>='
|
|
@@ -65,10 +65,10 @@ dependencies:
|
|
|
65
65
|
version: '0'
|
|
66
66
|
type: :development
|
|
67
67
|
prerelease: false
|
|
68
|
-
version_requirements: *
|
|
68
|
+
version_requirements: *70098036307200
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: rake
|
|
71
|
-
requirement: &
|
|
71
|
+
requirement: &70098036306500 !ruby/object:Gem::Requirement
|
|
72
72
|
none: false
|
|
73
73
|
requirements:
|
|
74
74
|
- - ! '>='
|
|
@@ -76,21 +76,43 @@ dependencies:
|
|
|
76
76
|
version: '0'
|
|
77
77
|
type: :development
|
|
78
78
|
prerelease: false
|
|
79
|
-
version_requirements: *
|
|
79
|
+
version_requirements: *70098036306500
|
|
80
80
|
- !ruby/object:Gem::Dependency
|
|
81
81
|
name: rspec
|
|
82
|
-
requirement: &
|
|
82
|
+
requirement: &70098036305440 !ruby/object:Gem::Requirement
|
|
83
83
|
none: false
|
|
84
84
|
requirements:
|
|
85
85
|
- - ! '>='
|
|
86
86
|
- !ruby/object:Gem::Version
|
|
87
|
-
version: '0'
|
|
87
|
+
version: '2.0'
|
|
88
|
+
type: :development
|
|
89
|
+
prerelease: false
|
|
90
|
+
version_requirements: *70098036305440
|
|
91
|
+
- !ruby/object:Gem::Dependency
|
|
92
|
+
name: rspec-rails
|
|
93
|
+
requirement: &70098036304660 !ruby/object:Gem::Requirement
|
|
94
|
+
none: false
|
|
95
|
+
requirements:
|
|
96
|
+
- - ! '>='
|
|
97
|
+
- !ruby/object:Gem::Version
|
|
98
|
+
version: '2.0'
|
|
99
|
+
type: :development
|
|
100
|
+
prerelease: false
|
|
101
|
+
version_requirements: *70098036304660
|
|
102
|
+
- !ruby/object:Gem::Dependency
|
|
103
|
+
name: mongoid-rspec
|
|
104
|
+
requirement: &70098036303960 !ruby/object:Gem::Requirement
|
|
105
|
+
none: false
|
|
106
|
+
requirements:
|
|
107
|
+
- - ! '>='
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: '1.5'
|
|
88
110
|
type: :development
|
|
89
111
|
prerelease: false
|
|
90
|
-
version_requirements: *
|
|
112
|
+
version_requirements: *70098036303960
|
|
91
113
|
- !ruby/object:Gem::Dependency
|
|
92
114
|
name: bundler
|
|
93
|
-
requirement: &
|
|
115
|
+
requirement: &70098036303500 !ruby/object:Gem::Requirement
|
|
94
116
|
none: false
|
|
95
117
|
requirements:
|
|
96
118
|
- - ! '>='
|
|
@@ -98,9 +120,10 @@ dependencies:
|
|
|
98
120
|
version: '0'
|
|
99
121
|
type: :development
|
|
100
122
|
prerelease: false
|
|
101
|
-
version_requirements: *
|
|
123
|
+
version_requirements: *70098036303500
|
|
102
124
|
description: Very simple Roles library without any authorization enforcement supporting
|
|
103
|
-
scope on resource objects (instance or class)
|
|
125
|
+
scope on resource objects (instance or class). Supports ActiveRecord and Mongoid
|
|
126
|
+
ORMs.
|
|
104
127
|
email:
|
|
105
128
|
- f.monbillard@gmail.com
|
|
106
129
|
executables: []
|
|
@@ -126,11 +149,14 @@ files:
|
|
|
126
149
|
- lib/rolify.rb
|
|
127
150
|
- lib/rolify/adapters/active_record/resource_adapter.rb
|
|
128
151
|
- lib/rolify/adapters/active_record/role_adapter.rb
|
|
152
|
+
- lib/rolify/adapters/active_record/scopes.rb
|
|
129
153
|
- lib/rolify/adapters/base.rb
|
|
130
154
|
- lib/rolify/adapters/mongoid/resource_adapter.rb
|
|
131
155
|
- lib/rolify/adapters/mongoid/role_adapter.rb
|
|
156
|
+
- lib/rolify/adapters/mongoid/scopes.rb
|
|
132
157
|
- lib/rolify/configure.rb
|
|
133
158
|
- lib/rolify/dynamic.rb
|
|
159
|
+
- lib/rolify/finders.rb
|
|
134
160
|
- lib/rolify/railtie.rb
|
|
135
161
|
- lib/rolify/resource.rb
|
|
136
162
|
- lib/rolify/role.rb
|
|
@@ -144,18 +170,23 @@ files:
|
|
|
144
170
|
- spec/rolify/role_spec.rb
|
|
145
171
|
- spec/rolify/shared_contexts.rb
|
|
146
172
|
- spec/rolify/shared_examples/shared_examples_for_add_role.rb
|
|
173
|
+
- spec/rolify/shared_examples/shared_examples_for_callbacks.rb
|
|
147
174
|
- spec/rolify/shared_examples/shared_examples_for_dynamic.rb
|
|
175
|
+
- spec/rolify/shared_examples/shared_examples_for_finders.rb
|
|
148
176
|
- spec/rolify/shared_examples/shared_examples_for_has_all_roles.rb
|
|
149
177
|
- spec/rolify/shared_examples/shared_examples_for_has_any_role.rb
|
|
150
178
|
- spec/rolify/shared_examples/shared_examples_for_has_role.rb
|
|
179
|
+
- spec/rolify/shared_examples/shared_examples_for_only_has_role.rb
|
|
151
180
|
- spec/rolify/shared_examples/shared_examples_for_remove_role.rb
|
|
152
181
|
- spec/rolify/shared_examples/shared_examples_for_roles.rb
|
|
182
|
+
- spec/rolify/shared_examples/shared_examples_for_scopes.rb
|
|
153
183
|
- spec/spec_helper.rb
|
|
154
184
|
- spec/support/adapters/active_record.rb
|
|
155
185
|
- spec/support/adapters/mongoid.rb
|
|
186
|
+
- spec/support/adapters/mongoid.yml
|
|
156
187
|
- spec/support/data.rb
|
|
157
188
|
- spec/support/schema.rb
|
|
158
|
-
homepage:
|
|
189
|
+
homepage: http://eppo.github.com/rolify/
|
|
159
190
|
licenses: []
|
|
160
191
|
post_install_message:
|
|
161
192
|
rdoc_options: []
|
|
@@ -187,14 +218,19 @@ test_files:
|
|
|
187
218
|
- spec/rolify/role_spec.rb
|
|
188
219
|
- spec/rolify/shared_contexts.rb
|
|
189
220
|
- spec/rolify/shared_examples/shared_examples_for_add_role.rb
|
|
221
|
+
- spec/rolify/shared_examples/shared_examples_for_callbacks.rb
|
|
190
222
|
- spec/rolify/shared_examples/shared_examples_for_dynamic.rb
|
|
223
|
+
- spec/rolify/shared_examples/shared_examples_for_finders.rb
|
|
191
224
|
- spec/rolify/shared_examples/shared_examples_for_has_all_roles.rb
|
|
192
225
|
- spec/rolify/shared_examples/shared_examples_for_has_any_role.rb
|
|
193
226
|
- spec/rolify/shared_examples/shared_examples_for_has_role.rb
|
|
227
|
+
- spec/rolify/shared_examples/shared_examples_for_only_has_role.rb
|
|
194
228
|
- spec/rolify/shared_examples/shared_examples_for_remove_role.rb
|
|
195
229
|
- spec/rolify/shared_examples/shared_examples_for_roles.rb
|
|
230
|
+
- spec/rolify/shared_examples/shared_examples_for_scopes.rb
|
|
196
231
|
- spec/spec_helper.rb
|
|
197
232
|
- spec/support/adapters/active_record.rb
|
|
198
233
|
- spec/support/adapters/mongoid.rb
|
|
234
|
+
- spec/support/adapters/mongoid.yml
|
|
199
235
|
- spec/support/data.rb
|
|
200
236
|
- spec/support/schema.rb
|