roles_active_record 0.2.5 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. data/Gemfile +13 -5
  2. data/Rakefile +13 -14
  3. data/VERSION +1 -1
  4. data/development.sqlite3 +0 -0
  5. data/lib/roles_active_record/role.rb +3 -0
  6. data/lib/roles_active_record/strategy/multi/many_roles.rb +38 -41
  7. data/lib/roles_active_record/strategy/multi/roles_mask.rb +22 -23
  8. data/lib/roles_active_record/strategy/multi.rb +54 -0
  9. data/lib/roles_active_record/strategy/shared.rb +26 -0
  10. data/lib/roles_active_record/strategy/single/admin_flag.rb +19 -18
  11. data/lib/roles_active_record/strategy/single/one_role.rb +35 -26
  12. data/lib/roles_active_record/strategy/single/role_string.rb +24 -19
  13. data/lib/roles_active_record/strategy/single.rb +34 -0
  14. data/roles_active_record.gemspec +54 -49
  15. data/spec/fixtures/many_roles_setup.rb +1 -1
  16. data/spec/fixtures/one_role_setup.rb +1 -1
  17. data/spec/migrations/many_roles/002_create_roles.rb +0 -1
  18. data/spec/migrations/roles_mask/005_add_roles_mask_to_users.rb +1 -1
  19. data/spec/roles_active_record/strategy/api.rb +214 -0
  20. data/spec/roles_active_record/strategy/api_examples.rb +213 -0
  21. data/spec/roles_active_record/strategy/multi/many_roles_spec.rb +27 -0
  22. data/spec/roles_active_record/strategy/multi/roles_mask_spec.rb +23 -0
  23. data/spec/roles_active_record/strategy/single/admin_flag_spec.rb +27 -0
  24. data/spec/roles_active_record/strategy/single/one_role_spec.rb +19 -0
  25. data/spec/roles_active_record/strategy/single/role_string_spec.rb +23 -0
  26. data/spec/roles_active_record/strategy/user_setup.rb +20 -0
  27. data/spec/spec_helper.rb +6 -1
  28. metadata +49 -63
  29. data/roles_for_ar.gemspec +0 -165
  30. data/spec/roles_active_record/admin_flag_spec.rb +0 -71
  31. data/spec/roles_active_record/many_roles_spec.rb +0 -69
  32. data/spec/roles_active_record/one_role_spec.rb +0 -68
  33. data/spec/roles_active_record/role_string_spec.rb +0 -68
  34. data/spec/roles_active_record/roles_mask_spec.rb +0 -68
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+ use_roles_strategy :admin_flag
3
+
4
+ class User < ActiveRecord::Base
5
+ include Roles::ActiveRecord
6
+
7
+ strategy :admin_flag, :default
8
+ valid_roles_are :admin, :guest
9
+ end
10
+
11
+ # DatabaseCleaner.start
12
+ def api_migrate
13
+ migrate('admin_flag')
14
+ end
15
+
16
+ def api_name
17
+ :admin_flag
18
+ end
19
+
20
+ load 'roles_active_record/strategy/api_examples.rb'
21
+
22
+ # describe "Roles for Active Record: admin_flag" do
23
+ # # require "roles_active_record/strategy/user_setup.rb"
24
+ # # require "roles_active_record/strategy/api"
25
+ # # require "roles_generic/rspec/api"
26
+ # end
27
+ #
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+ use_roles_strategy :one_role
3
+
4
+ def api_fixture
5
+ load 'fixtures/one_role_setup.rb'
6
+ end
7
+
8
+ def api_migrate
9
+ migrate('one_role')
10
+ end
11
+
12
+ def api_name
13
+ :one_role
14
+ end
15
+
16
+ load 'roles_active_record/strategy/api_examples.rb'
17
+
18
+
19
+
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+ use_roles_strategy :role_string
3
+
4
+ class User < ActiveRecord::Base
5
+ include Roles::ActiveRecord
6
+
7
+ strategy :role_string, :default
8
+ valid_roles_are :admin, :guest
9
+ end
10
+
11
+ def api_migrate
12
+ migrate('role_string')
13
+ end
14
+
15
+ def api_name
16
+ :role_string
17
+ end
18
+
19
+ load 'roles_active_record/strategy/api_examples.rb'
20
+
21
+
22
+
23
+
@@ -0,0 +1,20 @@
1
+ def default_user_setup
2
+ @guest_user = User.create(:name => 'Guest user')
3
+ @guest_user.add_roles :guest
4
+ # @guest_user.roles = :guest
5
+ @guest_user.save
6
+
7
+ puts "Guest roles: #{@guest_user.roles_list}"
8
+
9
+ @normal_user = User.create(:name => 'Normal user')
10
+ @normal_user.roles = :guest, :user
11
+ @normal_user.save
12
+
13
+ puts "Normal roles: #{@normal_user.roles_list}, #{@normal_user.inspect}"
14
+
15
+ @admin_user = User.create(:name => 'Admin user')
16
+ @admin_user.roles = :admin
17
+ @admin_user.save
18
+
19
+ puts "Admin roles: #{@admin_user.roles_list}, #{@admin_user.inspect}"
20
+ end
data/spec/spec_helper.rb CHANGED
@@ -15,7 +15,9 @@ module Rails
15
15
  end
16
16
  end
17
17
 
18
- path = File.dirname(__FILE__) + '/db/database.yml'
18
+ SPEC_DIR = File.dirname(__FILE__)
19
+
20
+ path = SPEC_DIR + '/db/database.yml'
19
21
  dbfile = File.open(path)
20
22
  dbconfig = YAML::load(dbfile)
21
23
  ActiveRecord::Base.establish_connection(dbconfig)
@@ -23,6 +25,9 @@ ActiveRecord::Base.logger = Logger.new(STDERR)
23
25
 
24
26
  DatabaseCleaner.strategy = :truncation
25
27
 
28
+ def api_fixture
29
+ end
30
+
26
31
  # $ rake VERSION=0
27
32
 
28
33
  def migration_folder(name)
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 2
8
- - 5
9
- version: 0.2.5
7
+ - 3
8
+ - 1
9
+ version: 0.3.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Kristian Mandrup
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-10-11 00:00:00 +02:00
17
+ date: 2010-11-20 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -28,9 +28,7 @@ dependencies:
28
28
  segments:
29
29
  - 2
30
30
  - 0
31
- - 0
32
- - rc
33
- version: 2.0.0.rc
31
+ version: "2.0"
34
32
  type: :development
35
33
  version_requirements: *id001
36
34
  - !ruby/object:Gem::Dependency
@@ -39,13 +37,12 @@ dependencies:
39
37
  requirement: &id002 !ruby/object:Gem::Requirement
40
38
  none: false
41
39
  requirements:
42
- - - ~>
40
+ - - ">="
43
41
  - !ruby/object:Gem::Version
44
42
  segments:
45
43
  - 0
46
44
  - 5
47
- - 2
48
- version: 0.5.2
45
+ version: "0.5"
49
46
  type: :development
50
47
  version_requirements: *id002
51
48
  - !ruby/object:Gem::Dependency
@@ -54,13 +51,13 @@ dependencies:
54
51
  requirement: &id003 !ruby/object:Gem::Requirement
55
52
  none: false
56
53
  requirements:
57
- - - ~>
54
+ - - ">="
58
55
  - !ruby/object:Gem::Version
59
56
  segments:
60
57
  - 0
61
- - 6
62
- - 5
63
- version: 0.6.5
58
+ - 7
59
+ - 0
60
+ version: 0.7.0
64
61
  type: :development
65
62
  version_requirements: *id003
66
63
  - !ruby/object:Gem::Dependency
@@ -74,8 +71,7 @@ dependencies:
74
71
  segments:
75
72
  - 3
76
73
  - 0
77
- - 0
78
- version: 3.0.0
74
+ version: "3.0"
79
75
  type: :runtime
80
76
  version_requirements: *id004
81
77
  - !ruby/object:Gem::Dependency
@@ -89,8 +85,7 @@ dependencies:
89
85
  segments:
90
86
  - 3
91
87
  - 0
92
- - 0
93
- version: 3.0.0
88
+ version: "3.0"
94
89
  type: :runtime
95
90
  version_requirements: *id005
96
91
  - !ruby/object:Gem::Dependency
@@ -104,8 +99,7 @@ dependencies:
104
99
  segments:
105
100
  - 1
106
101
  - 0
107
- - 0
108
- version: 1.0.0
102
+ version: "1.0"
109
103
  type: :runtime
110
104
  version_requirements: *id006
111
105
  - !ruby/object:Gem::Dependency
@@ -114,13 +108,12 @@ dependencies:
114
108
  requirement: &id007 !ruby/object:Gem::Requirement
115
109
  none: false
116
110
  requirements:
117
- - - ~>
111
+ - - ">="
118
112
  - !ruby/object:Gem::Version
119
113
  segments:
120
114
  - 0
121
115
  - 9
122
- - 3
123
- version: 0.9.3
116
+ version: "0.9"
124
117
  type: :runtime
125
118
  version_requirements: *id007
126
119
  - !ruby/object:Gem::Dependency
@@ -133,9 +126,9 @@ dependencies:
133
126
  - !ruby/object:Gem::Version
134
127
  segments:
135
128
  - 0
136
- - 2
137
- - 11
138
- version: 0.2.11
129
+ - 3
130
+ - 0
131
+ version: 0.3.0
139
132
  type: :runtime
140
133
  version_requirements: *id008
141
134
  - !ruby/object:Gem::Dependency
@@ -159,13 +152,13 @@ dependencies:
159
152
  requirement: &id010 !ruby/object:Gem::Requirement
160
153
  none: false
161
154
  requirements:
162
- - - ~>
155
+ - - ">="
163
156
  - !ruby/object:Gem::Version
164
157
  segments:
165
158
  - 0
166
- - 2
167
- - 5
168
- version: 0.2.5
159
+ - 3
160
+ - 0
161
+ version: 0.3.0
169
162
  type: :runtime
170
163
  version_requirements: *id010
171
164
  - !ruby/object:Gem::Dependency
@@ -174,13 +167,13 @@ dependencies:
174
167
  requirement: &id011 !ruby/object:Gem::Requirement
175
168
  none: false
176
169
  requirements:
177
- - - ">="
170
+ - - ~>
178
171
  - !ruby/object:Gem::Version
179
172
  segments:
180
173
  - 0
181
- - 2
182
- - 6
183
- version: 0.2.6
174
+ - 3
175
+ - 1
176
+ version: 0.3.1
184
177
  type: :runtime
185
178
  version_requirements: *id011
186
179
  - !ruby/object:Gem::Dependency
@@ -189,30 +182,15 @@ dependencies:
189
182
  requirement: &id012 !ruby/object:Gem::Requirement
190
183
  none: false
191
184
  requirements:
192
- - - ">="
185
+ - - ~>
193
186
  - !ruby/object:Gem::Version
194
187
  segments:
195
188
  - 0
196
189
  - 1
197
- - 5
198
- version: 0.1.5
190
+ - 6
191
+ version: 0.1.6
199
192
  type: :runtime
200
193
  version_requirements: *id012
201
- - !ruby/object:Gem::Dependency
202
- name: migration_assist
203
- prerelease: false
204
- requirement: &id013 !ruby/object:Gem::Requirement
205
- none: false
206
- requirements:
207
- - - ">="
208
- - !ruby/object:Gem::Version
209
- segments:
210
- - 0
211
- - 1
212
- - 5
213
- version: 0.1.5
214
- type: :runtime
215
- version_requirements: *id013
216
194
  description: Makes it easy to set a role strategy on your User model in Active Record
217
195
  email: kmandrup@gmail.com
218
196
  executables: []
@@ -244,8 +222,11 @@ files:
244
222
  - lib/roles_active_record/namespaces.rb
245
223
  - lib/roles_active_record/role.rb
246
224
  - lib/roles_active_record/strategy.rb
225
+ - lib/roles_active_record/strategy/multi.rb
247
226
  - lib/roles_active_record/strategy/multi/many_roles.rb
248
227
  - lib/roles_active_record/strategy/multi/roles_mask.rb
228
+ - lib/roles_active_record/strategy/shared.rb
229
+ - lib/roles_active_record/strategy/single.rb
249
230
  - lib/roles_active_record/strategy/single/admin_flag.rb
250
231
  - lib/roles_active_record/strategy/single/one_role.rb
251
232
  - lib/roles_active_record/strategy/single/role_string.rb
@@ -253,7 +234,6 @@ files:
253
234
  - lib/views/_single_role_selector.erb.html
254
235
  - logging.log
255
236
  - roles_active_record.gemspec
256
- - roles_for_ar.gemspec
257
237
  - sandbox/Rakefile
258
238
  - sandbox/add_role_to_users_migration.erb
259
239
  - sandbox/create_roles_migration.erb
@@ -278,7 +258,6 @@ files:
278
258
  - spec/migrations/role_string/002_add_role_string_to_users.rb
279
259
  - spec/migrations/roles_mask/005_add_roles_mask_to_users.rb
280
260
  - spec/migrations/users/001_create_users.rb
281
- - spec/roles_active_record/admin_flag_spec.rb
282
261
  - spec/roles_active_record/generators/roles_generator_spec.rb
283
262
  - spec/roles_active_record/generators/roles_migration/admin_flag_spec.rb
284
263
  - spec/roles_active_record/generators/roles_migration/many_roles_spec.rb
@@ -286,10 +265,14 @@ files:
286
265
  - spec/roles_active_record/generators/roles_migration/role_string_spec.rb
287
266
  - spec/roles_active_record/generators/roles_migration/roles_mask_spec.rb
288
267
  - spec/roles_active_record/generators/setup_generator_spec.rb
289
- - spec/roles_active_record/many_roles_spec.rb
290
- - spec/roles_active_record/one_role_spec.rb
291
- - spec/roles_active_record/role_string_spec.rb
292
- - spec/roles_active_record/roles_mask_spec.rb
268
+ - spec/roles_active_record/strategy/api.rb
269
+ - spec/roles_active_record/strategy/api_examples.rb
270
+ - spec/roles_active_record/strategy/multi/many_roles_spec.rb
271
+ - spec/roles_active_record/strategy/multi/roles_mask_spec.rb
272
+ - spec/roles_active_record/strategy/single/admin_flag_spec.rb
273
+ - spec/roles_active_record/strategy/single/one_role_spec.rb
274
+ - spec/roles_active_record/strategy/single/role_string_spec.rb
275
+ - spec/roles_active_record/strategy/user_setup.rb
293
276
  - spec/spec_helper.rb
294
277
  - tmp/rails/app/models/user.rb
295
278
  - tmp/rails/config/routes.rb
@@ -344,7 +327,6 @@ test_files:
344
327
  - spec/migrations/role_string/002_add_role_string_to_users.rb
345
328
  - spec/migrations/roles_mask/005_add_roles_mask_to_users.rb
346
329
  - spec/migrations/users/001_create_users.rb
347
- - spec/roles_active_record/admin_flag_spec.rb
348
330
  - spec/roles_active_record/generators/roles_generator_spec.rb
349
331
  - spec/roles_active_record/generators/roles_migration/admin_flag_spec.rb
350
332
  - spec/roles_active_record/generators/roles_migration/many_roles_spec.rb
@@ -352,8 +334,12 @@ test_files:
352
334
  - spec/roles_active_record/generators/roles_migration/role_string_spec.rb
353
335
  - spec/roles_active_record/generators/roles_migration/roles_mask_spec.rb
354
336
  - spec/roles_active_record/generators/setup_generator_spec.rb
355
- - spec/roles_active_record/many_roles_spec.rb
356
- - spec/roles_active_record/one_role_spec.rb
357
- - spec/roles_active_record/role_string_spec.rb
358
- - spec/roles_active_record/roles_mask_spec.rb
337
+ - spec/roles_active_record/strategy/api.rb
338
+ - spec/roles_active_record/strategy/api_examples.rb
339
+ - spec/roles_active_record/strategy/multi/many_roles_spec.rb
340
+ - spec/roles_active_record/strategy/multi/roles_mask_spec.rb
341
+ - spec/roles_active_record/strategy/single/admin_flag_spec.rb
342
+ - spec/roles_active_record/strategy/single/one_role_spec.rb
343
+ - spec/roles_active_record/strategy/single/role_string_spec.rb
344
+ - spec/roles_active_record/strategy/user_setup.rb
359
345
  - spec/spec_helper.rb
data/roles_for_ar.gemspec DELETED
@@ -1,165 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{roles_for_ar}
8
- s.version = "0.1.0"
9
-
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{2010-09-06}
13
- s.description = %q{Faciliatates adding a role strategy to your Active Record user model}
14
- s.email = %q{kmandrup@gmail.com}
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.markdown"
18
- ]
19
- s.files = [
20
- ".document",
21
- ".gitignore",
22
- ".rspec",
23
- "Gemfile",
24
- "LICENSE",
25
- "README.markdown",
26
- "Rakefile",
27
- "VERSION",
28
- "development.sqlite3",
29
- "lib/generators/active_record/roles/roles_generator.rb",
30
- "lib/generators/active_record/roles_migration/roles_migration_generator.rb",
31
- "lib/generators/active_record/roles_migration/templates/add_admin_flag_strategy.erb",
32
- "lib/generators/active_record/roles_migration/templates/add_many_roles_strategy.erb",
33
- "lib/generators/active_record/roles_migration/templates/add_one_role_strategy.erb",
34
- "lib/generators/active_record/roles_migration/templates/add_role_string_strategy.erb",
35
- "lib/generators/active_record/roles_migration/templates/add_roles_mask_to_users_migration.erb",
36
- "lib/generators/active_record/setup/setup_generator.rb",
37
- "lib/roles_active_record/base.rb",
38
- "lib/roles_active_record/namespaces.rb",
39
- "lib/roles_active_record/role.rb",
40
- "lib/roles_active_record/strategy.rb",
41
- "lib/roles_active_record/strategy/multi/many_roles.rb",
42
- "lib/roles_active_record/strategy/multi/roles_mask.rb",
43
- "lib/roles_active_record/strategy/single/admin_flag.rb",
44
- "lib/roles_active_record/strategy/single/one_role.rb",
45
- "lib/roles_active_record/strategy/single/role_string.rb",
46
- "lib/roles_for_active_record.rb",
47
- "lib/views/_multi_role_selector.erb.html",
48
- "lib/views/_single_role_selector.erb.html",
49
- "sandbox/Rakefile",
50
- "sandbox/add_role_to_users_migration.erb",
51
- "sandbox/create_roles_migration.erb",
52
- "sandbox/create_user_roles_migration.erb",
53
- "sandbox/database.log",
54
- "sandbox/database.yml",
55
- "sandbox/development.sqlite3",
56
- "sandbox/migrate/201002508_create_roles.rb",
57
- "sandbox/migrate/20102507_create_users.rb",
58
- "sandbox/model_base.rb",
59
- "sandbox/test.rb",
60
- "spec/db/database.yml",
61
- "spec/fixtures/many_roles_setup.rb",
62
- "spec/fixtures/one_role_setup.rb",
63
- "spec/migrations/admin_flag/004_add_admin_flag_to_users.rb",
64
- "spec/migrations/many_roles/002_create_roles.rb",
65
- "spec/migrations/many_roles/003_create_user_roles.rb",
66
- "spec/migrations/one_role/002_create_roles.rb",
67
- "spec/migrations/one_role/003_add_role_to_users.rb",
68
- "spec/migrations/role_string/002_add_role_string_to_users.rb",
69
- "spec/migrations/roles_mask/005_add_roles_mask_to_users.rb",
70
- "spec/migrations/users/001_create_users.rb",
71
- "spec/roles_active_record/admin_flag_spec.rb",
72
- "spec/roles_active_record/generators/migration_spec_helper.rb",
73
- "spec/roles_active_record/generators/roles_migration/admin_flag_spec.rb",
74
- "spec/roles_active_record/generators/roles_migration/many_roles_spec.rb",
75
- "spec/roles_active_record/generators/roles_migration/one_role_spec.rb",
76
- "spec/roles_active_record/generators/roles_migration/role_string_spec.rb",
77
- "spec/roles_active_record/generators/roles_migration/roles_mask_spec.rb",
78
- "spec/roles_active_record/generators/setup_generator_spec.rb",
79
- "spec/roles_active_record/many_roles_spec.rb",
80
- "spec/roles_active_record/one_role_spec.rb",
81
- "spec/roles_active_record/role_string_spec.rb",
82
- "spec/roles_active_record/roles_mask_spec.rb",
83
- "spec/spec_helper.rb"
84
- ]
85
- s.homepage = %q{http://github.com/kristianmandrup/roles_for_dm}
86
- s.rdoc_options = ["--charset=UTF-8"]
87
- s.require_paths = ["lib"]
88
- s.rubygems_version = %q{1.3.7}
89
- s.summary = %q{Faciliatates adding a role strategy to your Active Record user model}
90
- s.test_files = [
91
- "spec/fixtures/many_roles_setup.rb",
92
- "spec/fixtures/one_role_setup.rb",
93
- "spec/migrations/admin_flag/004_add_admin_flag_to_users.rb",
94
- "spec/migrations/many_roles/002_create_roles.rb",
95
- "spec/migrations/many_roles/003_create_user_roles.rb",
96
- "spec/migrations/one_role/002_create_roles.rb",
97
- "spec/migrations/one_role/003_add_role_to_users.rb",
98
- "spec/migrations/role_string/002_add_role_string_to_users.rb",
99
- "spec/migrations/roles_mask/005_add_roles_mask_to_users.rb",
100
- "spec/migrations/users/001_create_users.rb",
101
- "spec/roles_active_record/admin_flag_spec.rb",
102
- "spec/roles_active_record/generators/migration_spec_helper.rb",
103
- "spec/roles_active_record/generators/roles_migration/admin_flag_spec.rb",
104
- "spec/roles_active_record/generators/roles_migration/many_roles_spec.rb",
105
- "spec/roles_active_record/generators/roles_migration/one_role_spec.rb",
106
- "spec/roles_active_record/generators/roles_migration/role_string_spec.rb",
107
- "spec/roles_active_record/generators/roles_migration/roles_mask_spec.rb",
108
- "spec/roles_active_record/generators/setup_generator_spec.rb",
109
- "spec/roles_active_record/many_roles_spec.rb",
110
- "spec/roles_active_record/one_role_spec.rb",
111
- "spec/roles_active_record/role_string_spec.rb",
112
- "spec/roles_active_record/roles_mask_spec.rb",
113
- "spec/spec_helper.rb"
114
- ]
115
-
116
- if s.respond_to? :specification_version then
117
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
118
- s.specification_version = 3
119
-
120
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
121
- s.add_development_dependency(%q<rspec>, ["~> 2.0.0.beta.19"])
122
- s.add_development_dependency(%q<yaml>, [">= 0"])
123
- s.add_development_dependency(%q<logger>, [">= 0"])
124
- s.add_development_dependency(%q<database_cleaner>, [">= 0"])
125
- s.add_development_dependency(%q<generator_spec>, ["~> 0.4.5"])
126
- s.add_runtime_dependency(%q<active_record>, ["~> 3.0.0"])
127
- s.add_runtime_dependency(%q<arel>, ["~> 1.0.0"])
128
- s.add_runtime_dependency(%q<meta_where>, [">= 0.5.2"])
129
- s.add_runtime_dependency(%q<active_support>, ["~> 3.0.0"])
130
- s.add_runtime_dependency(%q<sugar-high>, ["~> 0.2.2"])
131
- s.add_runtime_dependency(%q<require_all>, ["~> 1.1.0"])
132
- s.add_runtime_dependency(%q<sugar-high>, ["~> 0.2.3"])
133
- s.add_runtime_dependency(%q<roles_generic>, ["~> 0.2.2"])
134
- else
135
- s.add_dependency(%q<rspec>, ["~> 2.0.0.beta.19"])
136
- s.add_dependency(%q<yaml>, [">= 0"])
137
- s.add_dependency(%q<logger>, [">= 0"])
138
- s.add_dependency(%q<database_cleaner>, [">= 0"])
139
- s.add_dependency(%q<generator_spec>, ["~> 0.4.5"])
140
- s.add_dependency(%q<active_record>, ["~> 3.0.0"])
141
- s.add_dependency(%q<arel>, ["~> 1.0.0"])
142
- s.add_dependency(%q<meta_where>, [">= 0.5.2"])
143
- s.add_dependency(%q<active_support>, ["~> 3.0.0"])
144
- s.add_dependency(%q<sugar-high>, ["~> 0.2.2"])
145
- s.add_dependency(%q<require_all>, ["~> 1.1.0"])
146
- s.add_dependency(%q<sugar-high>, ["~> 0.2.3"])
147
- s.add_dependency(%q<roles_generic>, ["~> 0.2.2"])
148
- end
149
- else
150
- s.add_dependency(%q<rspec>, ["~> 2.0.0.beta.19"])
151
- s.add_dependency(%q<yaml>, [">= 0"])
152
- s.add_dependency(%q<logger>, [">= 0"])
153
- s.add_dependency(%q<database_cleaner>, [">= 0"])
154
- s.add_dependency(%q<generator_spec>, ["~> 0.4.5"])
155
- s.add_dependency(%q<active_record>, ["~> 3.0.0"])
156
- s.add_dependency(%q<arel>, ["~> 1.0.0"])
157
- s.add_dependency(%q<meta_where>, [">= 0.5.2"])
158
- s.add_dependency(%q<active_support>, ["~> 3.0.0"])
159
- s.add_dependency(%q<sugar-high>, ["~> 0.2.2"])
160
- s.add_dependency(%q<require_all>, ["~> 1.1.0"])
161
- s.add_dependency(%q<sugar-high>, ["~> 0.2.3"])
162
- s.add_dependency(%q<roles_generic>, ["~> 0.2.2"])
163
- end
164
- end
165
-
@@ -1,71 +0,0 @@
1
- require 'spec_helper'
2
- use_roles_strategy :admin_flag
3
-
4
- class User < ActiveRecord::Base
5
- include Roles::ActiveRecord
6
-
7
- strategy :admin_flag, :default
8
- valid_roles_are :admin, :guest
9
- end
10
-
11
- describe "Roles for Active Record" do
12
- before do
13
- migrate('admin_flag')
14
- end
15
-
16
- before :each do
17
- @user = User.create(:name => 'Kristian')
18
- @user.roles = :guest
19
- @user.save
20
-
21
- @admin_user = User.create(:name => 'Admin user')
22
- @admin_user.roles = :admin
23
- @admin_user.save
24
- end
25
-
26
- describe "Admin flag strategy " do
27
-
28
- describe '#in_role' do
29
- it "should return first user maching role" do
30
- User.in_role(:guest).first.name.should == 'Kristian'
31
- User.in_role(:admin).first.name.should == 'Admin user'
32
- end
33
- end
34
-
35
- describe 'roles API' do
36
- it "should have admin user role to :admin" do
37
- @admin_user.role.should == :admin
38
- @admin_user.roles.should == [:admin]
39
- @admin_user.admin?.should be_true
40
-
41
- @admin_user.class.valid_roles.should == [:admin, :guest]
42
-
43
- @admin_user.has_role?(:guest).should be_false
44
-
45
- @admin_user.has_role?(:admin).should be_true
46
- @admin_user.is?(:admin).should be_true
47
- @admin_user.has_roles?(:admin).should be_true
48
- @admin_user.has?(:admin).should be_true
49
- end
50
-
51
- it "should have user role to :guest" do
52
- @user.roles.should == [:guest]
53
- @user.admin?.should be_false
54
-
55
- @user.has_role?(:guest).should be_true
56
- @user.has_role?(:admin).should be_false
57
- @user.is?(:admin).should be_false
58
-
59
- @user.has_roles?(:guest).should be_true
60
- @user.has?(:admin).should be_false
61
- end
62
-
63
- it "should set user role to :admin using =" do
64
- @user.roles = :admin
65
- @user.role.should == :admin
66
- @user.has_role?(:admin).should be_true
67
- end
68
- end
69
- end
70
- end
71
-
@@ -1,69 +0,0 @@
1
- require 'spec_helper'
2
- use_roles_strategy :many_roles
3
-
4
- migrate('many_roles')
5
-
6
- describe "Roles for Active Record" do
7
- before do
8
- migrate('many_roles')
9
- end
10
-
11
- context "default setup" do
12
-
13
- before :each do
14
- load 'fixtures/many_roles_setup.rb'
15
-
16
- @user = User.create(:name => 'Kristian')
17
- @user.add_roles :guest
18
- @user.save
19
-
20
- puts "user: #{@user.inspect}"
21
- puts "user roles: #{UserRole.all.inspect}"
22
- puts "roles: #{Role.all.inspect}"
23
-
24
- @admin_user = User.create(:name => 'Admin user')
25
- @admin_user.roles = :admin
26
- @admin_user.save
27
- end
28
-
29
- describe '#in_role' do
30
- it "should return first user matching role" do
31
- User.in_role(:guest).first.name.should == 'Kristian'
32
- User.in_role(:admin).first.name.should == 'Admin user'
33
- end
34
- end
35
-
36
- describe "Role API" do
37
- it "should have admin user role to :admin" do
38
- @admin_user.roles_list.first.should == :admin
39
- @admin_user.admin?.should be_true
40
-
41
- @admin_user.has_role?(:guest).should be_false
42
-
43
- @admin_user.has_role?(:admin).should be_true
44
- @admin_user.is?(:admin).should be_true
45
- @admin_user.has_roles?(:admin).should be_true
46
- @admin_user.has?(:admin).should be_true
47
- end
48
-
49
- it "should have user role to :guest" do
50
- @user.roles_list.first.should == :guest
51
- @user.admin?.should be_false
52
-
53
- @user.has_role?(:guest).should be_true
54
- @user.has_role?(:admin).should be_false
55
- @user.is?(:admin).should be_false
56
-
57
- @user.has_roles?(:admin).should be_false
58
- @user.has?(:admin).should be_false
59
- end
60
-
61
- it "should set user role to :admin using roles=" do
62
- @user.roles = :admin
63
- @user.roles_list.first.should == :admin
64
- @user.has_role?(:admin).should be_true
65
- end
66
- end
67
- end
68
- end
69
-