moiristo/deep_cloneable — pull request #15 by fractious (2012-07-19 15:52:29+00:00)
Title: HABTM associations cause duped record to be saved

When deep cloning a record with a `has_and_belongs_to_many` association the duped record is automatically saved due to the use of [`<<`](http://apidock.com/rails/v3.0.9/ActiveRecord/Associations/AssociationCollection/%3C%3C) on the association.

The attached patch fixes this issue by injecting the duped record into the `target` of the reverse associations instead of the `CollectionProxy` itself. It also adds assertions for each existing test to ensure that the duped record is a `new_record?`.