aegis 1.1.6 → 1.1.7

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.6
1
+ 1.1.7
data/aegis.gemspec CHANGED
@@ -1,15 +1,15 @@
1
1
  # Generated by jeweler
2
- # DO NOT EDIT THIS FILE
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{aegis}
8
- s.version = "1.1.6"
8
+ s.version = "1.1.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Henning Koch"]
12
- s.date = %q{2009-11-11}
12
+ s.date = %q{2010-02-24}
13
13
  s.description = %q{Aegis is a role-based permission system, where all users are given a role. It is possible to define detailed and complex permissions for each role very easily.}
14
14
  s.email = %q{github@makandra.de}
15
15
  s.extra_rdoc_files = [
@@ -105,3 +105,4 @@ Gem::Specification.new do |s|
105
105
  else
106
106
  end
107
107
  end
108
+
@@ -3,7 +3,7 @@ module Aegis
3
3
 
4
4
  def validates_role_name(options = {})
5
5
  validates_each :role_name do |record, attr, value|
6
- options[:message] ||= ActiveRecord::Errors.default_error_messages[:inclusion]
6
+ options[:message] ||= I18n.translate('activerecord.errors.messages.inclusion')
7
7
  role = ::Permissions.find_role_by_name(value)
8
8
  record.errors.add attr, options[:message] if role.nil?
9
9
  end
@@ -96,8 +96,8 @@ module Aegis
96
96
  alias_method_chain :respond_to?, :aegis_permissions
97
97
 
98
98
  def set_default_aegis_role_name
99
- if new_record?
100
- self.aegis_role_name ||= self.class.aegis_default_role_name
99
+ if new_record? && self.aegis_role_name.blank?
100
+ self.aegis_role_name = self.class.aegis_default_role_name
101
101
  end
102
102
  end
103
103
 
@@ -44,6 +44,10 @@ class HasRoleOptionsTest < ActiveSupport::TestCase
44
44
  should "create new instances with that role" do
45
45
  assert_equal :admin, TrustFundKid.new.role.name
46
46
  end
47
+
48
+ should "set that role if the initial role name is blank" do
49
+ assert_equal :admin, TrustFundKid.new(:role_name => "").role.name
50
+ end
47
51
 
48
52
  should "ignore the default if another role is given" do
49
53
  assert_equal :student, TrustFundKid.new(:role_name => "student").role.name
@@ -44,6 +44,12 @@ class ValidationTest < ActiveSupport::TestCase
44
44
 
45
45
  end
46
46
 
47
+ should "use add the default inclusion error message on role_name" do
48
+ @user.role_name = ""
49
+ @user.valid?
50
+ assert_equal I18n.translate('activerecord.errors.messages.inclusion'), @user.errors.on(:role_name)
51
+ end
52
+
47
53
  end
48
54
 
49
55
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aegis
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.6
4
+ version: 1.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henning Koch
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-11 00:00:00 +01:00
12
+ date: 2010-02-24 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15