ktopping_acl9 0.12.0 → 0.13.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/VERSION.yml +2 -2
- data/lib/acl9/model_extensions/for_subject.rb +3 -2
- data/test/roles_test.rb +16 -1
- data/test/support/schema.rb +1 -0
- metadata +2 -2
data/VERSION.yml
CHANGED
@@ -160,8 +160,9 @@ module Acl9
|
|
160
160
|
def delete_role(role)
|
161
161
|
if role
|
162
162
|
self.role_objects.delete role
|
163
|
-
|
164
|
-
|
163
|
+
if role.send(self._auth_subject_class_name.demodulize.tableize).empty?
|
164
|
+
role.destroy unless role.respond_to?(:system?) && role.system?
|
165
|
+
end
|
165
166
|
end
|
166
167
|
end
|
167
168
|
|
data/test/roles_test.rb
CHANGED
@@ -5,6 +5,21 @@ require 'support/models'
|
|
5
5
|
#Logger = ActiveRecord::Base.logger
|
6
6
|
load 'support/schema.rb'
|
7
7
|
|
8
|
+
|
9
|
+
class SystemRolesTest < Test::Unit::TestCase
|
10
|
+
it "should not delete a system role" do
|
11
|
+
Role.destroy_all
|
12
|
+
@role=Role.create(:name=>"admin", :system=>true)
|
13
|
+
@role.system.should be_true
|
14
|
+
Role.count.should==1
|
15
|
+
@user = User.create!
|
16
|
+
@user.has_role!(:admin)
|
17
|
+
Role.count.should==1
|
18
|
+
@user.has_no_role!(:admin)
|
19
|
+
Role.count.should==1
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
8
23
|
class RolesTest < Test::Unit::TestCase
|
9
24
|
before do
|
10
25
|
Role.destroy_all
|
@@ -269,6 +284,7 @@ class RolesTest < Test::Unit::TestCase
|
|
269
284
|
end
|
270
285
|
end
|
271
286
|
|
287
|
+
|
272
288
|
class RolesWithCustomClassNamesTest < Test::Unit::TestCase
|
273
289
|
before do
|
274
290
|
AnotherRole.destroy_all
|
@@ -352,4 +368,3 @@ class UsersRolesAndSubjectsWithNamespacedClassNamesTest < Test::Unit::TestCase
|
|
352
368
|
@user2.has_no_roles!
|
353
369
|
end
|
354
370
|
end
|
355
|
-
|
data/test/support/schema.rb
CHANGED