test/models/models.rb in mongoid-minitest-0.0.2 vs test/models/models.rb in mongoid-minitest-0.0.3

- old
+ new

@@ -10,20 +10,33 @@ field :age, type: Integer field :email, type: String field :role, type: String field :site, type: String - has_many :pets + index :name + has_one :account + has_many :pets + has_and_belongs_to_many :friends, class_name: "Person" + embeds_one :profile + embeds_many :sites + validates_presence_of(:name) validates_presence_of(:role, message: "no role") + + validates_confirmation_of(:password) + validates_acceptance_of(:terms_of_use) + validates_uniqueness_of(:email) validates_uniqueness_of(:login, scope: :site, case_sensitive: false) + validates_length_of(:password, minimum: 8, maximum: 16) validates_length_of(:login, in: 5..12) + validates_format_of(:email, with: /^([^\s]+)((?:[-a-z0-9]\.)[a-z]{2,})$/i) + validates_inclusion_of(:role, in: ["admin", "user"]) validates_exclusion_of(:email, in: ["foo@bar.com", "fizz@buzz.com"]) end class Pet @@ -34,6 +47,16 @@ class Account include Mongoid::Document belongs_to :person +end + +class Profile + include Mongoid::Document +end + +class Site + include Mongoid::Document + + embedded_in :person end