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.
- data/.rspec +1 -0
- data/README.markdown +14 -109
- data/Rakefile +5 -1
- data/VERSION +1 -1
- data/lib/generators/mongoid/roles/roles_generator.rb +48 -25
- data/lib/roles_mongoid.rb +9 -0
- data/lib/roles_mongoid/base.rb +35 -0
- data/lib/roles_mongoid/namespaces.rb +12 -0
- data/lib/roles_mongoid/role.rb +28 -0
- data/lib/roles_mongoid/strategy.rb +15 -0
- data/lib/roles_mongoid/strategy/multi/many_roles.rb +65 -0
- data/lib/roles_mongoid/strategy/multi/role_strings.rb +63 -0
- data/lib/roles_mongoid/strategy/multi/roles_mask.rb +81 -0
- data/lib/roles_mongoid/strategy/single/admin_flag.rb +53 -0
- data/lib/roles_mongoid/strategy/single/one_role.rb +56 -0
- data/lib/roles_mongoid/strategy/single/role_string.rb +51 -0
- data/roles_for_mongoid.gemspec +43 -24
- data/sandbox/roles_assign.rb +54 -0
- data/sandbox/single_role.rb +68 -0
- data/spec/roles_mongoid/admin_flag_spec.rb +74 -0
- data/spec/roles_mongoid/many_roles_spec.rb +74 -0
- data/spec/roles_mongoid/one_role_spec.rb +74 -0
- data/spec/roles_mongoid/role_string_spec.rb +73 -0
- data/spec/roles_mongoid/role_strings_spec.rb +73 -0
- data/spec/roles_mongoid/roles_mask_spec.rb +73 -0
- data/spec/spec_helper.rb +17 -7
- metadata +94 -25
- data/lib/roles_for_mongoid.rb +0 -1
- data/lib/roles_for_mongoid/role.rb +0 -4
- data/lib/roles_for_mongoid/strategies/admin_flag.rb +0 -17
- data/lib/roles_for_mongoid/strategies/inline_role.rb +0 -6
- data/lib/roles_for_mongoid/strategies/inline_roles.rb +0 -13
- data/lib/roles_for_mongoid/strategies/role_relations.rb +0 -34
- data/lib/roles_for_mongoid/strategies/roles_mask.rb +0 -52
- data/lib/roles_for_mongoid/user.rb +0 -12
- data/spec/roles_for_mongoid/user_admin_field_spec.rb +0 -24
- data/spec/roles_for_mongoid/user_inline_role_spec.rb +0 -23
- data/spec/roles_for_mongoid/user_inline_roles_spec.rb +0 -27
- data/spec/roles_for_mongoid/user_role_relations_spec.rb +0 -37
- data/spec/roles_for_mongoid/user_roles_mask_spec.rb +0 -29
- 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
|