roles_for_mongoid 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/.rspec +1 -0
  2. data/README.markdown +14 -109
  3. data/Rakefile +5 -1
  4. data/VERSION +1 -1
  5. data/lib/generators/mongoid/roles/roles_generator.rb +48 -25
  6. data/lib/roles_mongoid.rb +9 -0
  7. data/lib/roles_mongoid/base.rb +35 -0
  8. data/lib/roles_mongoid/namespaces.rb +12 -0
  9. data/lib/roles_mongoid/role.rb +28 -0
  10. data/lib/roles_mongoid/strategy.rb +15 -0
  11. data/lib/roles_mongoid/strategy/multi/many_roles.rb +65 -0
  12. data/lib/roles_mongoid/strategy/multi/role_strings.rb +63 -0
  13. data/lib/roles_mongoid/strategy/multi/roles_mask.rb +81 -0
  14. data/lib/roles_mongoid/strategy/single/admin_flag.rb +53 -0
  15. data/lib/roles_mongoid/strategy/single/one_role.rb +56 -0
  16. data/lib/roles_mongoid/strategy/single/role_string.rb +51 -0
  17. data/roles_for_mongoid.gemspec +43 -24
  18. data/sandbox/roles_assign.rb +54 -0
  19. data/sandbox/single_role.rb +68 -0
  20. data/spec/roles_mongoid/admin_flag_spec.rb +74 -0
  21. data/spec/roles_mongoid/many_roles_spec.rb +74 -0
  22. data/spec/roles_mongoid/one_role_spec.rb +74 -0
  23. data/spec/roles_mongoid/role_string_spec.rb +73 -0
  24. data/spec/roles_mongoid/role_strings_spec.rb +73 -0
  25. data/spec/roles_mongoid/roles_mask_spec.rb +73 -0
  26. data/spec/spec_helper.rb +17 -7
  27. metadata +94 -25
  28. data/lib/roles_for_mongoid.rb +0 -1
  29. data/lib/roles_for_mongoid/role.rb +0 -4
  30. data/lib/roles_for_mongoid/strategies/admin_flag.rb +0 -17
  31. data/lib/roles_for_mongoid/strategies/inline_role.rb +0 -6
  32. data/lib/roles_for_mongoid/strategies/inline_roles.rb +0 -13
  33. data/lib/roles_for_mongoid/strategies/role_relations.rb +0 -34
  34. data/lib/roles_for_mongoid/strategies/roles_mask.rb +0 -52
  35. data/lib/roles_for_mongoid/user.rb +0 -12
  36. data/spec/roles_for_mongoid/user_admin_field_spec.rb +0 -24
  37. data/spec/roles_for_mongoid/user_inline_role_spec.rb +0 -23
  38. data/spec/roles_for_mongoid/user_inline_roles_spec.rb +0 -27
  39. data/spec/roles_for_mongoid/user_role_relations_spec.rb +0 -37
  40. data/spec/roles_for_mongoid/user_roles_mask_spec.rb +0 -29
  41. data/spec/spec.opts +0 -1
@@ -1,29 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
-
3
- User.role_strategy :roles_mask
4
-
5
- describe "Roles for Mongoid" do
6
- describe "Roles mask strategy" do
7
-
8
- after :each do
9
- Database.teardown
10
- end
11
-
12
- before :each do
13
- User.available_roles = ['guest', 'admin', 'author']
14
-
15
- User.new(:name => 'Kristian', :roles => ['guest']).save
16
- User.new(:name => 'Admin user', :roles => ['admin']).save
17
- User.new(:name => 'Author', :roles => ['author']).save
18
- end
19
-
20
- it "should return first user matching role" do
21
- User.in_role('admin').first.name.should == 'Admin user'
22
- end
23
-
24
- it "should return all users matching any of the roles" do
25
- User.in_roles(['guest', 'admin']).size.should == 2
26
- User.in_roles('guest', 'admin').size.should == 2
27
- end
28
- end
29
- end
data/spec/spec.opts DELETED
@@ -1 +0,0 @@
1
- --color