mongoid/mongoid — pull request #2088 by jonhyman (2012-06-10 15:21:31+00:00)
Title: Allow the IdentityMap to get objects by the String representation of Moped::BSON::ObjectId.

This pull requests makes `Mongoid::IdentityMap.get(Person, person.id.to_s)` equivalent to `Mongoid::IdentityMap.get(Person, person.id)`.

The motivation behind this pull request was that in upgrading to Mongoid 3, not having this broke some of my controller tests that had expectations on an object. Here's a trivial example.

```ruby
# Say there's some method we want to ensure gets called when it is edited
person = FlightPassenger.create
person.should_receive(:check_name_against_terrorist_database)
post(:edit, {:flight_passenger => {:id => person.id, :first_name => "Jon"}, :format => :json}
```

In the controller action, the id would come through as a String. Because the IdentityMap would not be used, the object returned in the action would not have the same memory address as `person`, so the mock expectation would fail.