spec/support/adapters/mongoid.rb in rolify-3.1.0 vs spec/support/adapters/mongoid.rb in rolify-3.2.0.rc2
- old
+ new
@@ -1,10 +1,8 @@
require 'mongoid'
-Mongoid.configure do |config|
- config.master = Mongo::Connection.new.db("godfather")
-end
+Mongoid.load!("spec/support/adapters/mongoid.yml", :test)
::Mongoid::Document.module_eval do
def self.included(base)
base.extend Rolify
end
@@ -24,10 +22,21 @@
include Mongoid::Document
has_and_belongs_to_many :users
belongs_to :resource, :polymorphic => true
field :name, :type => String
+ index({ :name => 1 }, { :unique => true })
+ index(
+ {
+ :name => 1,
+ :resource_type => 1,
+ :resource_id => 1
+ },
+ { :unique => true }
+ )
+
+ scopify
end
class Forum
include Mongoid::Document
#resourcify done during specs setup to be able to use custom user classes
@@ -53,6 +62,17 @@
include Mongoid::Document
has_and_belongs_to_many :customers
belongs_to :resource, :polymorphic => true
field :name, :type => String
+ index({ :name => 1 }, { :unique => true })
+ index(
+ {
+ :name => 1,
+ :resource_type => 1,
+ :resource_id => 1
+ },
+ { :unique => true }
+ )
+
+ scopify
end