roles_generic 0.3.8 → 0.3.9

Sign up to get free protection for your applications and to get access to all the features.
data/Changelog.textile CHANGED
@@ -1,6 +1,10 @@
1
1
  h1. Changelog
2
2
 
3
- h2. V. 0.3.7.3
3
+ h2. May 10, 2011
4
+
5
+ Version 0.3.9
6
+
7
+ * Added #has_only_role? method which tests that the role subject only has the single role passed as argument
8
+ alias methods: #is_only? #has_only?
4
9
 
5
- * Feb 9/2011 - merged johanlunds/master to support Rubygems 1.5 and resolve dependencies
6
10
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.8
1
+ 0.3.9
@@ -118,6 +118,14 @@ module Roles::Generic::User
118
118
 
119
119
  alias_method :has?, :has_role?
120
120
  alias_method :is?, :has_roles?
121
+
122
+ def has_only_role? arg
123
+ raise ArgumentError, "Must take only a single argument that is a role name" if arg.send(:size) > 1 && arg.kind_of?(Array)
124
+ has_roles? [arg].flatten.first
125
+ end
126
+
127
+ alias_method :has_only?, :has_only_role?
128
+ alias_method :is_only?, :has_only_role?
121
129
 
122
130
  protected
123
131
 
@@ -51,8 +51,8 @@ describe 'Roles Generic API : READ' do
51
51
  end
52
52
 
53
53
  describe '#has_roles?' do
54
- it "should be true that the normal user has the roles :guest and :user" do
55
- @normal_user.has_roles?(:guest, :user).should be_true
54
+ it "should be true that the normal user has the roles :guest and :user" do
55
+ @normal_user.has_roles?(:user).should be_true
56
56
  end
57
57
 
58
58
  it "should NOT be true that the normal user has the roles :guest and :admin" do
@@ -64,13 +64,40 @@ describe 'Roles Generic API : READ' do
64
64
  end
65
65
  end
66
66
 
67
- describe '#has_roles?' do
67
+ describe '#has_only_role?' do
68
+ it "should be false that the normal user has only the role :guest" do
69
+ @normal_user.has_only_role?(:guest).should be_false
70
+ end
71
+
72
+ it "should Raise Error if passed an Array of roles" do
73
+ lambda { @normal_user.has_only_role?(:guest, :admin)}.should raise_error
74
+ end
75
+
76
+ it "should be true that the Guest user has only the role :guest" do
77
+ @guest_user.has_only_role?(:guest).should be_true
78
+ end
79
+ end
80
+
81
+ describe '#has_only?' do
82
+ it "should be true that the Guest user only has the role :guest" do
83
+ @guest_user.has_only?(:guest).should be_true
84
+ end
85
+ end
86
+
87
+ describe '#is_only?' do
88
+ it "should be true that the Guest user only is in the role :guest" do
89
+ @guest_user.is_only?(:guest).should be_true
90
+ end
91
+ end
92
+
93
+
94
+ describe '#has_any_role?' do
68
95
  it "should be true that the normal user has the roles :guest and :user" do
69
96
  @normal_user.has_any_role?(:guest, :user).should be_true
70
97
  end
71
98
 
72
- it "should be true that the normal user has one of the roles :guest or :admin" do
73
- @normal_user.has_any_role?(:guest, :admin).should be_true
99
+ it "should be true that the normal user has one of the roles :user or :admin" do
100
+ @normal_user.has_any_role?(:user, :admin).should be_true
74
101
  end
75
102
 
76
103
  it "should NOT be true that the user has the roles :admin" do
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{roles_generic}
8
- s.version = "0.3.8"
8
+ s.version = "0.3.9"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Kristian Mandrup"]
12
- s.date = %q{2011-03-04}
11
+ s.authors = [%q{Kristian Mandrup}]
12
+ s.date = %q{2011-05-10}
13
13
  s.description = %q{Generic role strategies sharing the same API. Easy to insert in any model}
14
14
  s.email = %q{kmandrup@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -86,8 +86,8 @@ Gem::Specification.new do |s|
86
86
  "wiki/strategies/roles_string.textile"
87
87
  ]
88
88
  s.homepage = %q{http://github.com/kristianmandrup/roles_generic}
89
- s.require_paths = ["lib"]
90
- s.rubygems_version = %q{1.6.1}
89
+ s.require_paths = [%q{lib}]
90
+ s.rubygems_version = %q{1.8.0}
91
91
  s.summary = %q{Generic role strategies sharing the same API}
92
92
  s.test_files = [
93
93
  "spec/generator_spec_helper.rb",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roles_generic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.8
4
+ version: 0.3.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-03-04 00:00:00.000000000 +01:00
13
- default_executable:
12
+ date: 2011-05-10 00:00:00.000000000Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: require_all
17
- requirement: &2158642760 !ruby/object:Gem::Requirement
16
+ requirement: &2158411500 !ruby/object:Gem::Requirement
18
17
  none: false
19
18
  requirements:
20
19
  - - ~>
@@ -22,10 +21,10 @@ dependencies:
22
21
  version: 1.2.0
23
22
  type: :runtime
24
23
  prerelease: false
25
- version_requirements: *2158642760
24
+ version_requirements: *2158411500
26
25
  - !ruby/object:Gem::Dependency
27
26
  name: activesupport
28
- requirement: &2158642140 !ruby/object:Gem::Requirement
27
+ requirement: &2158410820 !ruby/object:Gem::Requirement
29
28
  none: false
30
29
  requirements:
31
30
  - - ! '>='
@@ -33,10 +32,10 @@ dependencies:
33
32
  version: 3.0.1
34
33
  type: :runtime
35
34
  prerelease: false
36
- version_requirements: *2158642140
35
+ version_requirements: *2158410820
37
36
  - !ruby/object:Gem::Dependency
38
37
  name: sugar-high
39
- requirement: &2158641440 !ruby/object:Gem::Requirement
38
+ requirement: &2158410180 !ruby/object:Gem::Requirement
40
39
  none: false
41
40
  requirements:
42
41
  - - ~>
@@ -44,10 +43,10 @@ dependencies:
44
43
  version: 0.4.0
45
44
  type: :runtime
46
45
  prerelease: false
47
- version_requirements: *2158641440
46
+ version_requirements: *2158410180
48
47
  - !ruby/object:Gem::Dependency
49
48
  name: rails_artifactor
50
- requirement: &2158640820 !ruby/object:Gem::Requirement
49
+ requirement: &2158409600 !ruby/object:Gem::Requirement
51
50
  none: false
52
51
  requirements:
53
52
  - - ~>
@@ -55,10 +54,10 @@ dependencies:
55
54
  version: 0.3.3
56
55
  type: :runtime
57
56
  prerelease: false
58
- version_requirements: *2158640820
57
+ version_requirements: *2158409600
59
58
  - !ruby/object:Gem::Dependency
60
59
  name: rspec
61
- requirement: &2158639420 !ruby/object:Gem::Requirement
60
+ requirement: &2158409080 !ruby/object:Gem::Requirement
62
61
  none: false
63
62
  requirements:
64
63
  - - ! '>='
@@ -66,10 +65,10 @@ dependencies:
66
65
  version: 2.4.1
67
66
  type: :development
68
67
  prerelease: false
69
- version_requirements: *2158639420
68
+ version_requirements: *2158409080
70
69
  - !ruby/object:Gem::Dependency
71
70
  name: generator-spec
72
- requirement: &2158638800 !ruby/object:Gem::Requirement
71
+ requirement: &2158408540 !ruby/object:Gem::Requirement
73
72
  none: false
74
73
  requirements:
75
74
  - - ! '>='
@@ -77,10 +76,10 @@ dependencies:
77
76
  version: 0.7.3
78
77
  type: :development
79
78
  prerelease: false
80
- version_requirements: *2158638800
79
+ version_requirements: *2158408540
81
80
  - !ruby/object:Gem::Dependency
82
81
  name: require_all
83
- requirement: &2158637700 !ruby/object:Gem::Requirement
82
+ requirement: &2158403860 !ruby/object:Gem::Requirement
84
83
  none: false
85
84
  requirements:
86
85
  - - ~>
@@ -88,10 +87,10 @@ dependencies:
88
87
  version: 1.2.0
89
88
  type: :runtime
90
89
  prerelease: false
91
- version_requirements: *2158637700
90
+ version_requirements: *2158403860
92
91
  - !ruby/object:Gem::Dependency
93
92
  name: activesupport
94
- requirement: &2158636900 !ruby/object:Gem::Requirement
93
+ requirement: &2158403140 !ruby/object:Gem::Requirement
95
94
  none: false
96
95
  requirements:
97
96
  - - ! '>='
@@ -99,10 +98,10 @@ dependencies:
99
98
  version: 3.0.1
100
99
  type: :runtime
101
100
  prerelease: false
102
- version_requirements: *2158636900
101
+ version_requirements: *2158403140
103
102
  - !ruby/object:Gem::Dependency
104
103
  name: sugar-high
105
- requirement: &2158636280 !ruby/object:Gem::Requirement
104
+ requirement: &2158402520 !ruby/object:Gem::Requirement
106
105
  none: false
107
106
  requirements:
108
107
  - - ~>
@@ -110,7 +109,7 @@ dependencies:
110
109
  version: 0.4.0
111
110
  type: :runtime
112
111
  prerelease: false
113
- version_requirements: *2158636280
112
+ version_requirements: *2158402520
114
113
  description: Generic role strategies sharing the same API. Easy to insert in any model
115
114
  email: kmandrup@gmail.com
116
115
  executables: []
@@ -186,7 +185,6 @@ files:
186
185
  - wiki/strategies/role_strings.textile
187
186
  - wiki/strategies/roles_mask.textile
188
187
  - wiki/strategies/roles_string.textile
189
- has_rdoc: true
190
188
  homepage: http://github.com/kristianmandrup/roles_generic
191
189
  licenses: []
192
190
  post_install_message:
@@ -207,7 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
207
205
  version: '0'
208
206
  requirements: []
209
207
  rubyforge_project:
210
- rubygems_version: 1.6.1
208
+ rubygems_version: 1.8.0
211
209
  signing_key:
212
210
  specification_version: 3
213
211
  summary: Generic role strategies sharing the same API