spec/support/adapters/mongoid.rb in rolify-4.1.1 vs spec/support/adapters/mongoid.rb in rolify-5.0.0

- old
+ new

@@ -1,9 +1,14 @@ -require 'mongoid' +load File.dirname(__FILE__) + '/utils/mongoid.rb' -Mongoid.load!("spec/support/adapters/mongoid.yml", :test) +load_mongoid_config +begin + Mongo::Logger.logger.level = ::Logger::FATAL +rescue NameError +end + ::Mongoid::Document.module_eval do def self.included(base) base.extend Rolify end end @@ -11,18 +16,21 @@ Rolify.use_mongoid # Standard user and role classes class User include Mongoid::Document + default_scope -> { order_by id: 'asc' } + rolify field :login, :type => String end # Standard user and role classes class StrictUser include Mongoid::Document + default_scope -> { order_by id: 'asc' } rolify strict: true field :login, :type => String end @@ -46,10 +54,11 @@ end # Resourcifed and rolifed at the same time class HumanResource include Mongoid::Document + default_scope -> { order_by id: 'asc' } resourcify :resources rolify field :login, :type => String end @@ -72,17 +81,19 @@ #end # Custom role and class names class Customer include Mongoid::Document + default_scope -> { order_by id: 'asc' } rolify :role_cname => "Privilege" field :login, :type => String end class Privilege include Mongoid::Document + default_scope -> { order_by id: 'asc' } has_and_belongs_to_many :customers belongs_to :resource, :polymorphic => true scopify field :name, :type => String @@ -98,17 +109,19 @@ # Namespaced models module Admin class Moderator include Mongoid::Document + default_scope -> { order_by id: 'asc' } rolify :role_cname => "Admin::Right" field :login, :type => String end class Right include Mongoid::Document + default_scope -> { order_by id: 'asc' } has_and_belongs_to_many :moderators, :class_name => 'Admin::Moderator' belongs_to :resource, :polymorphic => true scopify field :name, :type => String @@ -124,17 +137,19 @@ end # Resources classes class Forum include Mongoid::Document + default_scope -> { order_by id: 'asc' } #resourcify done during specs setup to be able to use custom user classes field :name, :type => String end class Group include Mongoid::Document + default_scope -> { order_by id: 'asc' } #resourcify done during specs setup to be able to use custom user classes field :name, :type => String field :parent_id, :type => Integer @@ -143,17 +158,19 @@ end end class Team include Mongoid::Document + default_scope -> { order_by id: 'asc' } #resourcify done during specs setup to be able to use custom user classes field :team_code, :type => Integer field :name, :type => String end class Organization include Mongoid::Document + default_scope -> { order_by id: 'asc' } end class Company < Organization end