roles_generic 0.2.7 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +25 -13
- data/Rakefile +7 -5
- data/VERSION +1 -1
- data/lib/generators/{roles_model → roles_generic}/roles/roles_generator.rb +8 -15
- data/lib/roles_generic/base.rb +40 -2
- data/lib/roles_generic/generic/role.rb +2 -16
- data/lib/roles_generic/generic/role_util.rb +30 -0
- data/lib/roles_generic/generic/user/implementation.rb +108 -6
- data/lib/roles_generic/generic/user/multi_impl.rb +27 -0
- data/lib/roles_generic/generic/user/single_impl.rb +24 -0
- data/lib/roles_generic/generic.rb +1 -1
- data/lib/roles_generic/role.rb +1 -0
- data/lib/roles_generic/rspec/api/completeness.rb +22 -0
- data/lib/roles_generic/rspec/api/full.rb +5 -0
- data/lib/roles_generic/rspec/api/read_api.rb +119 -0
- data/lib/roles_generic/rspec/api/simple_check.rb +11 -0
- data/lib/roles_generic/rspec/api/user_class_api.rb +31 -0
- data/lib/roles_generic/rspec/api/write_api.rb +50 -0
- data/lib/roles_generic/rspec/test_it.rb +2 -0
- data/lib/roles_generic/rspec/user_setup.rb +6 -0
- data/lib/roles_generic/strategy/multi/many_roles.rb +12 -19
- data/lib/roles_generic/strategy/multi/role_strings.rb +15 -12
- data/lib/roles_generic/strategy/multi/roles_mask.rb +20 -16
- data/lib/roles_generic/strategy/multi/roles_string.rb +14 -11
- data/lib/roles_generic/strategy/single/admin_flag.rb +24 -13
- data/lib/roles_generic/strategy/single/one_role.rb +19 -18
- data/lib/roles_generic/strategy/single/role_string.rb +16 -11
- data/lib/roles_generic.rb +1 -0
- data/roles_generic.gemspec +60 -46
- data/spec/generator_spec_helper.rb +1 -1
- data/spec/{generators → roles_generic/generators}/admin_flag_generator_spec.rb +2 -3
- data/spec/{generators → roles_generic/generators}/many_roles_generator_spec.rb +3 -2
- data/spec/{generators → roles_generic/generators}/one_role_generator_spec.rb +3 -2
- data/spec/{generators → roles_generic/generators}/role_string_generator_spec.rb +2 -2
- data/spec/{generators → roles_generic/generators}/role_strings_generator_spec.rb +2 -2
- data/spec/{generators → roles_generic/generators}/roles_mask_generator_spec.rb +2 -2
- data/spec/{generators → roles_generic/generators}/roles_string_generator_spec.rb +2 -2
- data/spec/roles_generic/strategy/multi/many_roles_spec.rb +26 -0
- data/spec/roles_generic/strategy/multi/role_strings_spec.rb +21 -0
- data/spec/roles_generic/strategy/multi/roles_mask_spec.rb +20 -0
- data/spec/roles_generic/strategy/multi/roles_string_spec.rb +21 -0
- data/spec/roles_generic/strategy/single/admin_flag_spec.rb +20 -0
- data/spec/roles_generic/strategy/single/one_role_spec.rb +27 -0
- data/spec/roles_generic/strategy/single/role_string_spec.rb +21 -0
- metadata +72 -50
- data/spec/roles_generic/admin_flag_spec.rb +0 -66
- data/spec/roles_generic/many_roles_spec.rb +0 -64
- data/spec/roles_generic/one_role_spec.rb +0 -71
- data/spec/roles_generic/role_string_spec.rb +0 -65
- data/spec/roles_generic/role_strings_spec.rb +0 -58
- data/spec/roles_generic/roles_mask_spec.rb +0 -57
- data/spec/roles_generic/roles_string_spec.rb +0 -58
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
use_roles_strategy :role_strings
|
3
|
-
|
4
|
-
class User
|
5
|
-
include Roles::Generic
|
6
|
-
|
7
|
-
attr_accessor :name
|
8
|
-
|
9
|
-
strategy :role_strings, :default
|
10
|
-
|
11
|
-
valid_roles_are :admin, :user
|
12
|
-
|
13
|
-
def initialize name, *new_roles
|
14
|
-
self.name = name
|
15
|
-
self.roles = new_roles
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
describe "Generic RoleStrings role strategy" do
|
21
|
-
context "default setup" do
|
22
|
-
|
23
|
-
before :each do
|
24
|
-
@admin_user = User.new 'Admin user', :admin
|
25
|
-
@user = User.new 'User', :user
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should have admin user role to :admin" do
|
29
|
-
@admin_user.roles.first.should == :admin
|
30
|
-
@admin_user.admin?.should be_true
|
31
|
-
|
32
|
-
@admin_user.has_role?(:user).should be_false
|
33
|
-
|
34
|
-
@admin_user.has_role?(:admin).should be_true
|
35
|
-
@admin_user.is?(:admin).should be_true
|
36
|
-
@admin_user.has_roles?(:admin).should be_true
|
37
|
-
@admin_user.has?(:admin).should be_true
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should have user role to :user" do
|
41
|
-
@user.roles.first.should == :user
|
42
|
-
@user.admin?.should be_false
|
43
|
-
|
44
|
-
@user.has_role?(:user).should be_true
|
45
|
-
@user.has_role?(:admin).should be_false
|
46
|
-
@user.is?(:admin).should be_false
|
47
|
-
|
48
|
-
@user.has_roles?(:admin).should be_false
|
49
|
-
@user.has?(:admin).should be_false
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should set user role to :admin using roles=" do
|
53
|
-
@user.roles = :admin
|
54
|
-
@user.roles.first.should == :admin
|
55
|
-
@user.has_role?(:admin).should be_true
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
use_roles_strategy :roles_mask
|
3
|
-
|
4
|
-
class User
|
5
|
-
include Roles::Generic
|
6
|
-
|
7
|
-
attr_accessor :name
|
8
|
-
|
9
|
-
strategy :roles_mask, :default
|
10
|
-
|
11
|
-
valid_roles_are :admin, :user
|
12
|
-
|
13
|
-
def initialize name, *new_roles
|
14
|
-
self.name = name
|
15
|
-
self.roles = new_roles
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe "Generic RolesMask role strategy" do
|
20
|
-
context "default setup" do
|
21
|
-
|
22
|
-
before :each do
|
23
|
-
@admin_user = User.new 'Admin user', :admin
|
24
|
-
@user = User.new 'User', :user
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should have admin user role to :admin" do
|
28
|
-
@admin_user.roles_list.first.should == :admin
|
29
|
-
@admin_user.admin?.should be_true
|
30
|
-
|
31
|
-
@admin_user.has_role?(:user).should be_false
|
32
|
-
|
33
|
-
@admin_user.has_role?(:admin).should be_true
|
34
|
-
@admin_user.is?(:admin).should be_true
|
35
|
-
@admin_user.has_roles?(:admin).should be_true
|
36
|
-
@admin_user.has?(:admin).should be_true
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should have user role to :user" do
|
40
|
-
@user.roles_list.first.should == :user
|
41
|
-
@user.admin?.should be_false
|
42
|
-
|
43
|
-
@user.has_role?(:user).should be_true
|
44
|
-
@user.has_role?(:admin).should be_false
|
45
|
-
@user.is?(:admin).should be_false
|
46
|
-
|
47
|
-
@user.has_roles?(:admin).should be_false
|
48
|
-
@user.has?(:admin).should be_false
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should set user role to :admin using roles=" do
|
52
|
-
@user.roles = :admin
|
53
|
-
@user.roles_list.first.should == :admin
|
54
|
-
@user.has_role?(:admin).should be_true
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
use_roles_strategy :roles_string
|
3
|
-
|
4
|
-
class User
|
5
|
-
include Roles::Generic
|
6
|
-
|
7
|
-
attr_accessor :name
|
8
|
-
|
9
|
-
strategy :roles_string, :default
|
10
|
-
|
11
|
-
valid_roles_are :admin, :user
|
12
|
-
|
13
|
-
def initialize name, *new_roles
|
14
|
-
self.name = name
|
15
|
-
self.roles = new_roles
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
describe "Generic RoleStrings role strategy" do
|
21
|
-
context "default setup" do
|
22
|
-
|
23
|
-
before :each do
|
24
|
-
@admin_user = User.new 'Admin user', :admin
|
25
|
-
@user = User.new 'User', :user
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should have admin user role to :admin" do
|
29
|
-
@admin_user.roles.first.should == :admin
|
30
|
-
@admin_user.admin?.should be_true
|
31
|
-
|
32
|
-
@admin_user.has_role?(:user).should be_false
|
33
|
-
|
34
|
-
@admin_user.has_role?(:admin).should be_true
|
35
|
-
@admin_user.is?(:admin).should be_true
|
36
|
-
@admin_user.has_roles?(:admin).should be_true
|
37
|
-
@admin_user.has?(:admin).should be_true
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should have user role to :user" do
|
41
|
-
@user.roles.first.should == :user
|
42
|
-
@user.admin?.should be_false
|
43
|
-
|
44
|
-
@user.has_role?(:user).should be_true
|
45
|
-
@user.has_role?(:admin).should be_false
|
46
|
-
@user.is?(:admin).should be_false
|
47
|
-
|
48
|
-
@user.has_roles?(:admin).should be_false
|
49
|
-
@user.has?(:admin).should be_false
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should set user role to :admin using roles=" do
|
53
|
-
@user.roles = :admin
|
54
|
-
@user.roles.first.should == :admin
|
55
|
-
@user.has_role?(:admin).should be_true
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|