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.
@@ -1,5 +1,5 @@
1
1
  ---
2
+ :major: 0
2
3
  :build:
3
- :minor: 12
4
+ :minor: 13
4
5
  :patch: 0
5
- :major: 0
@@ -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
- role.destroy if role.send(self._auth_subject_class_name.demodulize.tableize).empty?
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
 
@@ -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
-
@@ -1,6 +1,7 @@
1
1
  ActiveRecord::Schema.define(:version => 0) do
2
2
  create_table "roles", :force => true do |t|
3
3
  t.string "name", :limit => 40
4
+ t.boolean "system", :default=>false
4
5
  t.string "authorizable_type", :limit => 40
5
6
  t.string "authorizable_id"
6
7
  t.datetime "created_at"
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 12
7
+ - 13
8
8
  - 0
9
- version: 0.12.0
9
+ version: 0.13.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - oleg dashevskii