troles 0.5.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +17 -12
- data/Gemfile.lock +42 -38
- data/README.textile +29 -0
- data/Rakefile +1 -23
- data/VERSION +1 -1
- data/lib/trole.rb +1 -5
- data/lib/trole_groups/macros.rb +1 -2
- data/lib/trole_groups.rb +4 -7
- data/lib/troles/adapters/active_record/config.rb +28 -39
- data/lib/troles/common/api/read.rb +1 -0
- data/lib/troles/common/config/class_methods.rb +44 -0
- data/lib/troles/common/config/schema/helpers.rb +0 -79
- data/lib/troles/common/config/schema.rb +40 -37
- data/lib/troles/common/config/valid_roles.rb +13 -1
- data/lib/troles/common/config.rb +46 -79
- data/lib/troles/common/dependencies.rb +1 -0
- data/lib/troles/common/macros/configuration/base_loader.rb +6 -10
- data/lib/troles/common/macros/configuration/config_loader.rb +2 -7
- data/lib/troles/common/macros/configuration/storage_loader.rb +3 -8
- data/lib/troles/common/macros/configuration/strategy_loader.rb +3 -17
- data/lib/troles/common/macros/configuration.rb +2 -5
- data/lib/troles/common/macros.rb +2 -3
- data/lib/troles/common/marshaller.rb +1 -2
- data/lib/troles/common/operations.rb +1 -2
- data/lib/troles/common.rb +1 -6
- data/lib/troles/config.rb +0 -8
- data/lib/troles/macros.rb +0 -2
- data/lib/troles/storage/base_many.rb +1 -1
- data/lib/troles/storage.rb +1 -6
- data/lib/troles/strategy.rb +2 -0
- data/lib/troles.rb +3 -2
- data/spec/active_record/migrations/many/bit_many.rb +1 -7
- data/spec/active_record/migrations/many/custom_join.rb +2 -9
- data/spec/active_record/migrations/many/join_ref_many.rb +1 -10
- data/spec/active_record/migrations/many/ref_many.rb +7 -8
- data/spec/active_record/migrations/many/string_many.rb +1 -7
- data/spec/active_record/migrations/one/bit_one.rb +1 -5
- data/spec/active_record/migrations/one/ref_one.rb +1 -6
- data/spec/active_record/migrations/one/string_one.rb +1 -5
- data/spec/active_record_helper.rb +8 -4
- data/spec/factories.rb +2 -0
- data/spec/trole_groups/api/read_api_spec.rb +1 -1
- data/spec/trole_groups/strategies/{ref_many.rb → ref_many_spec.rb} +0 -0
- data/spec/troles/common/config/schema_spec.rb +5 -0
- data/spec/troles/common/multi_roles_spec.rb +2 -2
- data/spec/troles/marshaller/bitmask_spec.rb +11 -5
- data/spec/troles/marshaller/generic_spec.rb +17 -0
- data/spec/troles/storage/bit_many_spec.rb +20 -0
- data/spec/troles/storage/ref_many_spec.rb +20 -0
- data/spec/troles/storage/string_many_spec.rb +19 -0
- data/spec/troles/strategies/string_many_spec.rb +1 -1
- data/troles.gemspec +24 -43
- metadata +39 -122
- data/lib/troles/common/config/schema/role_helpers.rb +0 -27
@@ -1,10 +1,20 @@
|
|
1
|
+
#
|
2
|
+
# @author Kristian Mandrup
|
3
|
+
#
|
4
|
+
# Valid roles module
|
5
|
+
# Adds methods for operating on/with valid roles
|
6
|
+
#
|
1
7
|
module Troles::Common
|
2
8
|
class Config
|
3
|
-
module ValidRoles
|
9
|
+
module ValidRoles
|
10
|
+
# Add a list of valid roles
|
11
|
+
# @param [Array<Symbol>] names of roles to make valid
|
4
12
|
def add_valid_roles *roles
|
5
13
|
valid_roles =valid_roles & roles
|
6
14
|
end
|
7
15
|
|
16
|
+
# Set a list of valid roles
|
17
|
+
# @param [Array<Symbol>] names of roles to make valid
|
8
18
|
def valid_roles= *roles
|
9
19
|
vrs = roles.flatten.map{|r| r.to_s.alpha_numeric}.map(&:to_sym).uniq
|
10
20
|
|
@@ -13,6 +23,8 @@ module Troles::Common
|
|
13
23
|
@valid_roles ||= vrs
|
14
24
|
end
|
15
25
|
|
26
|
+
# Get the list of valid roles
|
27
|
+
# @return [Array<Symbol>] names of roles that are currently valid
|
16
28
|
def valid_roles
|
17
29
|
raise "No valid roles defined" if !@valid_roles || @valid_roles.empty?
|
18
30
|
@valid_roles
|
data/lib/troles/common/config.rb
CHANGED
@@ -1,130 +1,97 @@
|
|
1
1
|
module Troles::Common
|
2
2
|
class Config
|
3
|
-
|
4
|
-
autoload :StaticRoles, 'troles/common/config/static_roles'
|
5
|
-
autoload :Schema, 'troles/common/config/schema'
|
6
|
-
autoload :SchemaHelpers, 'troles/common/config/schema_helpers'
|
3
|
+
autoload_modules :ValidRoles, :StaticRoles, :Schema, :SchemaHelpers, :ClassMethods
|
7
4
|
|
8
5
|
def self.sub_modules
|
9
6
|
[:valid_roles, :static_roles, :schema]
|
10
7
|
end
|
11
|
-
|
8
|
+
|
9
|
+
# include sub-modules as needed
|
12
10
|
sub_modules.each do |name|
|
13
11
|
send :include, "Troles::Common::Config::#{name.to_s.camelize}".constantize
|
14
12
|
end
|
15
13
|
|
16
|
-
attr_accessor :subject_class, :strategy, :log_on, :generic
|
14
|
+
attr_accessor :subject_class, :strategy, :log_on, :generic
|
17
15
|
attr_writer :orm
|
18
|
-
|
16
|
+
|
17
|
+
# configure Config object with subject class and various options
|
19
18
|
def initialize subject_class, options = {}
|
19
|
+
raise ArgumentError, "The first argument must be the Class which is the subject of the behavior" unless subject_class.is_a?(Class)
|
20
20
|
@subject_class = subject_class
|
21
|
-
|
21
|
+
|
22
22
|
apply_options! options
|
23
23
|
end
|
24
24
|
|
25
|
-
|
26
|
-
attr_reader :default_orm, :auto_load
|
27
|
-
attr_accessor :log_on
|
28
|
-
|
29
|
-
def log_on?
|
30
|
-
log_on || false
|
31
|
-
end
|
32
|
-
|
33
|
-
def default_orm= orm
|
34
|
-
@default_orm ||= orm
|
35
|
-
end
|
36
|
-
|
37
|
-
def auto_load= mode
|
38
|
-
raise "Autoload must be set to true or false" if ![true, false].include? mode
|
39
|
-
@auto_load = mode
|
40
|
-
end
|
25
|
+
extend ClassMethods
|
41
26
|
|
42
|
-
|
43
|
-
|
27
|
+
# Call setter for each key/value pair
|
28
|
+
def apply_options! options = {}
|
29
|
+
options.each_pair do |key, value|
|
30
|
+
send("#{key}=", value) if self.respond_to?(:"#{key}=")
|
44
31
|
end
|
32
|
+
end
|
45
33
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
protected
|
55
|
-
|
56
|
-
|
57
|
-
def auto_config_setings
|
58
|
-
@auto_config_setings ||= auto_config_defaults
|
59
|
-
end
|
60
|
-
|
61
|
-
# default auto_config settings
|
62
|
-
def auto_config_defaults
|
63
|
-
{:models => true, :relations => true, :fields => true}
|
64
|
-
end
|
34
|
+
# Configure subject with behavior
|
35
|
+
# First apply any remaining options needed
|
36
|
+
# Then configure models if configured to do do
|
37
|
+
def configure! options = {}
|
38
|
+
apply_options! options
|
39
|
+
configure_models if auto_config?(:models)
|
65
40
|
end
|
66
41
|
|
42
|
+
# is logging on?
|
67
43
|
def log_on?
|
68
44
|
log_on || Troles::Config.log_on
|
69
45
|
end
|
70
46
|
|
47
|
+
# get the auto configuration settings hash
|
71
48
|
def auto_config
|
72
|
-
|
49
|
+
@auto_config ||= {}
|
73
50
|
end
|
74
|
-
|
51
|
+
|
52
|
+
# is a certain type of auto configuration enabled?
|
75
53
|
def auto_config? name
|
76
|
-
return
|
54
|
+
return auto_config[name] if !auto_config[name].nil?
|
77
55
|
Troles::Config.auto_config?(name)
|
78
56
|
end
|
79
57
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
|
-
def configure! options = {}
|
87
|
-
apply_options! options
|
88
|
-
configure_models if auto_config?(:models)
|
89
|
-
end
|
90
|
-
|
91
|
-
# protected
|
92
|
-
|
93
|
-
def auto_config_setings
|
94
|
-
@auto_config_setings ||= {}
|
95
|
-
end
|
96
|
-
|
97
|
-
def role_field
|
98
|
-
@role_field ||= begin
|
99
|
-
default_role_field
|
58
|
+
# Get the main field name that is used for the behavior added, fx :troles for roles behavior
|
59
|
+
def main_field
|
60
|
+
@main_field ||= begin
|
61
|
+
default_main_field
|
100
62
|
end
|
101
63
|
end
|
64
|
+
alias_method :role_field, :main_field
|
102
65
|
|
103
|
-
|
66
|
+
# Set the main field of the behavior
|
67
|
+
def main_field= field_name
|
104
68
|
name = field_name.to_s.alpha_numeric.to_sym
|
105
|
-
raise ArgumentException, "Not a valid
|
106
|
-
@
|
69
|
+
raise ArgumentException, "Not a valid field name: #{field_name}" if !valid_field_name?(name)
|
70
|
+
@main_field ||= name
|
107
71
|
end
|
72
|
+
alias_method :role_field=, :main_field=
|
108
73
|
|
109
|
-
|
110
|
-
|
74
|
+
# get the default name of the main field
|
75
|
+
# for roles, it depends on the singularity (one or many) of the strategy
|
76
|
+
# see (#singularity)
|
77
|
+
def default_main_field
|
78
|
+
@default_main_field ||= (singularity == :many) ? :troles : :trole
|
111
79
|
end
|
80
|
+
alias_method :default_role_field, :default_main_field
|
112
81
|
|
82
|
+
# get the orm name
|
113
83
|
def orm
|
114
84
|
@orm || self.class.default_orm
|
115
85
|
end
|
116
86
|
|
87
|
+
# get the singularity (one or many) of the strategy
|
117
88
|
def singularity
|
118
89
|
@singularity ||= (strategy =~ /_many$/) ? :many : :one
|
119
90
|
end
|
120
91
|
|
121
|
-
#
|
122
|
-
# raise ArgumentError, "Must be :many or :one" if ![:one, :many].include?(value)
|
123
|
-
# @singularity ||= value
|
124
|
-
# end
|
125
|
-
|
92
|
+
# is it a generic strategy/orm ?
|
126
93
|
def generic?
|
127
|
-
return true if orm.nil?
|
94
|
+
return true if orm.nil? || orm == :generic
|
128
95
|
@generic.nil? ? false : @generic
|
129
96
|
end
|
130
97
|
end
|
@@ -1,7 +1,9 @@
|
|
1
|
-
module Troles::Macros
|
1
|
+
module Troles::Common::Macros
|
2
2
|
class Configuration
|
3
3
|
class BaseLoader
|
4
4
|
attr_reader :strategy, :orm
|
5
|
+
|
6
|
+
include ClassExt
|
5
7
|
|
6
8
|
def initialize strategy, orm
|
7
9
|
@strategy = strategy
|
@@ -12,16 +14,10 @@ module Troles::Macros
|
|
12
14
|
(strategy =~ /_many$/) ? :many : :one
|
13
15
|
end
|
14
16
|
|
15
|
-
def
|
16
|
-
|
17
|
-
full_name.constantize
|
18
|
-
true
|
19
|
-
rescue
|
20
|
-
# puts "module #{full_name} not found!"
|
21
|
-
false
|
22
|
-
end
|
17
|
+
def strategy_class
|
18
|
+
strategy.to_s.camelize
|
23
19
|
end
|
24
|
-
|
20
|
+
|
25
21
|
def base_class
|
26
22
|
"Base#{singularity.to_s.camelize}"
|
27
23
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module Troles::Macros
|
1
|
+
module Troles::Common::Macros
|
2
2
|
class Configuration
|
3
3
|
class ConfigLoader < BaseLoader
|
4
4
|
|
@@ -7,12 +7,7 @@ module Troles::Macros
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def config_class
|
10
|
-
|
11
|
-
"#{orm_namespace}::Config".constantize
|
12
|
-
rescue
|
13
|
-
# use generic if no ORM specific strategy found!
|
14
|
-
"#{namespace}::Config".constantize
|
15
|
-
end
|
10
|
+
@config_class ||= find_first_class("#{orm_namespace}::Config", "#{namespace}::Config")
|
16
11
|
end
|
17
12
|
end
|
18
13
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module Troles::Macros
|
1
|
+
module Troles::Common::Macros
|
2
2
|
class Configuration
|
3
3
|
class StorageLoader < BaseLoader
|
4
4
|
|
@@ -7,13 +7,8 @@ module Troles::Macros
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def storage_class
|
10
|
-
|
11
|
-
|
12
|
-
rescue
|
13
|
-
# use generic if no ORM specific strategy found!
|
14
|
-
"#{namespace}::Storage::#{strategy.to_s.camelize}".constantize
|
15
|
-
end
|
16
|
-
end
|
10
|
+
@storage_class ||= find_first_class("#{orm_namespace}::Storage::#{strategy_class}", "#{namespace}::Storage::#{strategy_class}")
|
11
|
+
end
|
17
12
|
end
|
18
13
|
end
|
19
14
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module Troles::Macros
|
1
|
+
module Troles::Common::Macros
|
2
2
|
class Configuration
|
3
3
|
class StrategyLoader < BaseLoader
|
4
4
|
|
@@ -13,25 +13,11 @@ module Troles::Macros
|
|
13
13
|
protected
|
14
14
|
|
15
15
|
def orm_strategy_module
|
16
|
-
@orm_strategy_module ||=
|
17
|
-
mods_found = ["#{orm_namespace}::Strategy::#{strategy.to_s.camelize}", "#{namespace}::Strategy::#{base_class}"].select do |full_name|
|
18
|
-
try_module(full_name)
|
19
|
-
end
|
20
|
-
!mods_found.empty? ? mods_found.first.constantize : nil
|
21
|
-
end
|
16
|
+
@orm_strategy_module ||= find_first_module("#{orm_namespace}::Strategy::#{strategy_class}", "#{namespace}::Strategy::#{base_class}")
|
22
17
|
end
|
23
18
|
|
24
19
|
def generic_strategy_module strategy_name, options
|
25
|
-
@generic_module ||=
|
26
|
-
base_class = base_name(strategy_name)
|
27
|
-
|
28
|
-
# use generic if no ORM specific strategy found!
|
29
|
-
ns = namespace(strategy_name, options)
|
30
|
-
mods_found = ["#{namespace}::Strategy::#{strategy.to_s.camelize}", "#{namespace}::Strategy::#{base_class}"].select do |full_name|
|
31
|
-
try_module(full_name)
|
32
|
-
end
|
33
|
-
!mods_found.empty? ? mods_found.first.constantize : nil
|
34
|
-
end
|
20
|
+
@generic_module ||= find_first_module("#{namespace}::Strategy::#{strategy_class}", "#{namespace}::Strategy::#{base_class}")
|
35
21
|
end
|
36
22
|
end
|
37
23
|
end
|
@@ -1,10 +1,7 @@
|
|
1
|
-
module Troles
|
1
|
+
module Troles::Common
|
2
2
|
module Macros
|
3
3
|
class Configuration
|
4
|
-
|
5
|
-
autoload :ConfigLoader, 'troles/common/macros/configuration/config_loader'
|
6
|
-
autoload :StrategyLoader, 'troles/common/macros/configuration/strategy_loader'
|
7
|
-
autoload :StorageLoader, 'troles/common/macros/configuration/storage_loader'
|
4
|
+
autoload_modules :BaseLoader, :ConfigLoader, :StrategyLoader, :StorageLoader
|
8
5
|
|
9
6
|
attr_reader :strategy, :singularity, :orm, :auto_load, :options, :subject_class
|
10
7
|
|
data/lib/troles/common/macros.rb
CHANGED
@@ -9,9 +9,9 @@
|
|
9
9
|
# troles_strategy :bit_many
|
10
10
|
#
|
11
11
|
|
12
|
-
module Troles
|
12
|
+
module Troles::Common
|
13
13
|
module Macros
|
14
|
-
|
14
|
+
autoload_modules :Configuration
|
15
15
|
|
16
16
|
def troles_strategy strategy, options = {}, &block
|
17
17
|
configuration = Configuration.new self, strategy, options
|
@@ -35,4 +35,3 @@ module Troles
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
Module.send :include, Troles::Macros
|
data/lib/troles/common.rb
CHANGED
@@ -7,11 +7,6 @@ require 'troles/common/dependencies'
|
|
7
7
|
|
8
8
|
module Troles
|
9
9
|
module Common
|
10
|
-
|
11
|
-
autoload :Config, 'troles/common/config'
|
12
|
-
autoload :Operations, 'troles/common/operations'
|
13
|
-
autoload :Marshaller, 'troles/common/marshaller'
|
14
|
-
autoload :Storage, 'troles/common/storage'
|
15
|
-
autoload :EventManager, 'troles/common/event_manager'
|
10
|
+
autoload_modules :Api, :Config, :Operations, :Marshaller, :Storage, :EventManager, :Macros
|
16
11
|
end
|
17
12
|
end
|
data/lib/troles/config.rb
CHANGED
data/lib/troles/macros.rb
CHANGED
@@ -11,7 +11,7 @@ module Troles
|
|
11
11
|
# @param [Array<Symbol>] list of role names to find Roles for
|
12
12
|
# @return [Array<Role>] references to Role instances
|
13
13
|
def find_roles *roles
|
14
|
-
role_model.where(:name => roles.flatten)
|
14
|
+
role_model.where(:name => roles.flatten)
|
15
15
|
end
|
16
16
|
|
17
17
|
# get list of embedded Role instances
|
data/lib/troles/storage.rb
CHANGED
@@ -4,11 +4,6 @@
|
|
4
4
|
#
|
5
5
|
module Troles
|
6
6
|
module Storage
|
7
|
-
|
8
|
-
autoload :BitMany, 'troles/storage/bit_many'
|
9
|
-
autoload :EmbedMany, 'troles/storage/embed_many'
|
10
|
-
autoload :RefMany, 'troles/storage/ref_many'
|
11
|
-
autoload :JoinRefMany, 'troles/storage/join_ref_many'
|
12
|
-
autoload :StringMany, 'troles/storage/string_many'
|
7
|
+
autoload_modules :BaseMany, :BitMany, :EmbedMany, :RefMany, :JoinRefMany, :StringMany
|
13
8
|
end
|
14
9
|
end
|
data/lib/troles/strategy.rb
CHANGED
data/lib/troles.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'troles/common'
|
2
|
-
require 'troles/macros'
|
3
2
|
|
4
3
|
module Troles
|
5
|
-
autoload_modules :Config, :Common, :Api, :Operations, :Strategy, :Storage
|
4
|
+
autoload_modules :Config, :Common, :Api, :Operations, :Strategy, :Storage, :Macros
|
6
5
|
end
|
6
|
+
|
7
|
+
Module.send :include, Troles::Common::Macros
|
@@ -1,9 +1,8 @@
|
|
1
1
|
class CreateCustomJoin < ActiveRecord::Migration
|
2
|
-
def
|
3
|
-
# down
|
4
|
-
|
2
|
+
def change
|
5
3
|
create_table :users do |t|
|
6
4
|
# implicit user_id binds to user_id of roles_users join table
|
5
|
+
t.integer :troles
|
7
6
|
t.string :name
|
8
7
|
t.timestamps
|
9
8
|
end
|
@@ -21,11 +20,5 @@ class CreateCustomJoin < ActiveRecord::Migration
|
|
21
20
|
t.timestamps
|
22
21
|
end
|
23
22
|
end
|
24
|
-
|
25
|
-
def self.down
|
26
|
-
drop_table :users
|
27
|
-
drop_table :roles
|
28
|
-
drop_table :users_roles
|
29
|
-
end
|
30
23
|
end
|
31
24
|
|
@@ -1,7 +1,5 @@
|
|
1
1
|
class CreateJoinRefMany < ActiveRecord::Migration
|
2
|
-
def
|
3
|
-
# down
|
4
|
-
|
2
|
+
def change
|
5
3
|
create_table :users do |t|
|
6
4
|
# implicit user_id binds to user_id of roles_users join table
|
7
5
|
t.string :name
|
@@ -13,7 +11,6 @@ class CreateJoinRefMany < ActiveRecord::Migration
|
|
13
11
|
t.integer :user_id
|
14
12
|
t.integer :role_id
|
15
13
|
end
|
16
|
-
|
17
14
|
|
18
15
|
create_table :roles do |t|
|
19
16
|
# implicit role_id binds to role_id of roles_users join table
|
@@ -21,11 +18,5 @@ class CreateJoinRefMany < ActiveRecord::Migration
|
|
21
18
|
t.timestamps
|
22
19
|
end
|
23
20
|
end
|
24
|
-
|
25
|
-
def self.down
|
26
|
-
drop_table :users
|
27
|
-
drop_table :roles
|
28
|
-
drop_table :users_roles
|
29
|
-
end
|
30
21
|
end
|
31
22
|
|
@@ -1,23 +1,22 @@
|
|
1
1
|
class CreateRefMany < ActiveRecord::Migration
|
2
|
-
def
|
3
|
-
# down
|
4
|
-
|
2
|
+
def change
|
5
3
|
create_table :users do |t|
|
6
4
|
# implicit user_id binds to user_id of roles_users join table
|
7
5
|
t.string :name
|
8
6
|
t.timestamps
|
9
7
|
end
|
10
8
|
|
9
|
+
# join table
|
10
|
+
# create_table :roles_users, :id => false do |t|
|
11
|
+
# t.integer :user_id
|
12
|
+
# t.integer :role_id
|
13
|
+
# end
|
14
|
+
|
11
15
|
create_table :roles do |t|
|
12
16
|
# implicit role_id binds to role_id of roles_users join table
|
13
17
|
t.string :name
|
14
18
|
t.timestamps
|
15
19
|
end
|
16
20
|
end
|
17
|
-
|
18
|
-
def self.down
|
19
|
-
drop_table :users
|
20
|
-
drop_table :roles
|
21
|
-
end
|
22
21
|
end
|
23
22
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class CreateRefOne < ActiveRecord::Migration
|
2
|
-
def
|
2
|
+
def change
|
3
3
|
create_table :users do |t|
|
4
4
|
t.string :name
|
5
5
|
t.integer :role_id # a user can have ONE role
|
@@ -11,10 +11,5 @@ class CreateRefOne < ActiveRecord::Migration
|
|
11
11
|
t.timestamps
|
12
12
|
end
|
13
13
|
end
|
14
|
-
|
15
|
-
def self.down
|
16
|
-
drop_table :users
|
17
|
-
drop_table :roles
|
18
|
-
end
|
19
14
|
end
|
20
15
|
|
@@ -21,12 +21,16 @@ ActiveRecord::Base.logger = Logger.new(STDERR)
|
|
21
21
|
DatabaseCleaner.strategy = :truncation
|
22
22
|
|
23
23
|
def migration_folder(name)
|
24
|
-
|
24
|
+
File.dirname(__FILE__) + "/active_record/migrations/#{name}"
|
25
25
|
end
|
26
26
|
|
27
|
-
def migrate
|
28
|
-
singularity = (name
|
29
|
-
|
27
|
+
def migrate name = :ref_many
|
28
|
+
singularity = (name.to_s =~ /_many/) ? :many : :one
|
29
|
+
migration_file = migration_folder(File.join [singularity, name].map(&:to_s))
|
30
|
+
puts "mig file: #{migration_file}"
|
31
|
+
require migration_file
|
32
|
+
|
33
|
+
"Create#{name.to_s.camelize}".constantize.new.change
|
30
34
|
end
|
31
35
|
|
32
36
|
RSpec.configure do |config|
|
data/spec/factories.rb
CHANGED
@@ -18,7 +18,7 @@ shared_examples_for "TroleGroup Read API" do
|
|
18
18
|
|
19
19
|
# adding single roles and role groups together produces union of roles from all :)
|
20
20
|
user.add_roles :editor
|
21
|
-
user.role_list.should include(:
|
21
|
+
user.role_list.should include(:blogger, :blog_editor, :admin, :blog_admin)
|
22
22
|
end
|
23
23
|
|
24
24
|
specify { user.has_any_rolegroup?(:blog_admin, :admin).should be_true }
|
File without changes
|