aegis 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.0
1
+ 2.1.1
data/aegis.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{aegis}
8
- s.version = "2.1.0"
8
+ s.version = "2.1.1"
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", "Tobias Kraze"]
12
- s.date = %q{2010-07-25}
12
+ s.date = %q{2010-07-26}
13
13
  s.description = %q{Aegis is an authorization solution for Ruby on Rails that supports roles and a RESTish, resource-style declaration of permission rules.}
14
14
  s.email = %q{henning.koch@makandra.de}
15
15
  s.extra_rdoc_files = [
@@ -25,6 +25,10 @@ module Aegis
25
25
  end.compact
26
26
  end
27
27
 
28
+ send :define_method, :has_role? do |role_name|
29
+ role_names.include?(role_name.to_s)
30
+ end
31
+
28
32
  metaclass.send :define_method, :validates_role do |*validate_options|
29
33
  validate_options = validate_options[0] || {}
30
34
 
@@ -6,6 +6,7 @@ describe Aegis::HasRole do
6
6
 
7
7
  @permissions_class = permissions_class = Class.new(Aegis::Permissions) do
8
8
  role :user
9
+ role :moderator
9
10
  role :admin
10
11
  end
11
12
 
@@ -22,6 +23,7 @@ describe Aegis::HasRole do
22
23
  user = @user_class.new
23
24
  user.should respond_to(:role)
24
25
  user.should respond_to(:roles)
26
+ user.should respond_to(:has_role?)
25
27
  end
26
28
 
27
29
  it "should allow a default for new records" do
@@ -104,6 +106,26 @@ describe Aegis::HasRole do
104
106
 
105
107
  end
106
108
 
109
+ describe 'has_role?' do
110
+
111
+ it "should return true if the user has the given role name" do
112
+ user = @user_class.new(:role_name => 'admin, user')
113
+ user.should have_role('admin')
114
+ user.should have_role('user')
115
+ end
116
+
117
+ it "should return false if the user does not have the given role name" do
118
+ user = @user_class.new(:role_name => 'admin, user')
119
+ user.should_not have_role('moderator')
120
+ end
121
+
122
+ it "should allow to query the role name as a symbol instead of a string" do
123
+ user = @user_class.new(:role_name => 'admin, user')
124
+ user.should have_role(:admin)
125
+ end
126
+
127
+ end
128
+
107
129
  describe 'method_missing' do
108
130
 
109
131
  it "should delegate may...? messages to the permissions class" do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 2
7
7
  - 1
8
- - 0
9
- version: 2.1.0
8
+ - 1
9
+ version: 2.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Henning Koch
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-25 00:00:00 +02:00
18
+ date: 2010-07-26 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies: []
21
21