mongoid/mongoid — pull request #1715 by blt04 (2012-02-13 21:20:59+00:00)
Title: Serialization with embedded relations is inconsistent

If I add an embedded relation *before* saving a document, the relation is serialized (without the :includes option):

person = Person.new
person.write_attributes(:title => "President")
person.addresses.build(:street => "Kudamm")
person.save
person.serializable_hash
=> {'title' => 'President', 'addresses' => [{'street' => 'Kudamm'], ...}

But if the relation is added *after* saving a document, the relation is not serialized:

person = Person.new
person.write_attributes(:title => "President")
person.save
person.addresses.build(:street => "Kudamm")
person.save
person.serializable_hash
=> {'title' => 'President', ...}

If I pass `:includes => ['addresses']` to the `serialize_hash` method, it works in both situations. What is the intended behavior when `:includes` is not specified?

The attached specs demonstrate the problem. 2 of the 4 added specs fail.

(I'm using mongoid 2.4.3)