mccormicka/Mockgoose — pull request #45 by seansullicbt (2014-04-03 21:50:19+00:00)
Title: Properly pull ObjectId from embedded array of ObjectIds by skipping clone

We have a case where there was a Schema that contained a property with an array of ObjectIds, similar to the Parent Model in the Mockgoose tests. Using Mockgoose, we were not able to properly use $pull on one of these items.

I tracked the breaking code down into the utils.js library where calling _.clone() on an item that was an ObjectId causes the value to get mangled and subsequent comparisons to fail in the pullItem() function found in PullOperation.js.

This is the best way I could sort out to solve this issue. I'm open to suggestions if you have a better way of handling this, but checking if an object is explicitly an ObjectId and skipping the _.clone() works as outlined by the provided test.