spec/mongoid/association/referenced/has_many_models.rb in mongoid-7.2.5 vs spec/mongoid/association/referenced/has_many_models.rb in mongoid-7.2.6
- old
+ new
@@ -22,9 +22,26 @@
include Mongoid::Document
belongs_to :company, class_name: 'HmmCompany'
end
+class HmmOwner
+ include Mongoid::Document
+
+ has_many :pets, class_name: 'HmmPet', inverse_of: :current_owner
+
+ field :name, type: String
+end
+
+class HmmPet
+ include Mongoid::Document
+
+ belongs_to :current_owner, class_name: 'HmmOwner', inverse_of: :pets, optional: true
+ belongs_to :previous_owner, class_name: 'HmmOwner', inverse_of: nil, optional: true
+
+ field :name, type: String
+end
+
class HmmSchool
include Mongoid::Document
has_many :students, class_name: 'HmmStudent'