spec/mongoid/association/referenced/has_many_models.rb in mongoid-7.3.5 vs spec/mongoid/association/referenced/has_many_models.rb in mongoid-7.4.0
- old
+ new
@@ -1,7 +1,6 @@
# frozen_string_literal: true
-# encoding: utf-8
class HmmCompany
include Mongoid::Document
field :p, type: Integer
@@ -73,6 +72,24 @@
class HmmBusSeat
include Mongoid::Document
# No belongs_to :bus
+end
+
+class HmmTrainer
+ include Mongoid::Document
+
+ field :name, type: String
+
+ has_many :animals, class_name: 'HmmAnimal', scope: :reptile
+end
+
+class HmmAnimal
+ include Mongoid::Document
+
+ field :taxonomy, type: String
+
+ scope :reptile, -> { where(taxonomy: 'reptile') }
+
+ belongs_to :trainer, class_name: 'HmmTrainer', scope: -> { where(name: 'Dave') }
end