mongoid/mongoid — Issue #1418: find(id) returns stale data with enabled identity_map and Mongoid::Versioning
Author: dimaulupov
Created: 2011-11-09 07:56:23+00:00
State: open

Mongoid documents with versioning included and with enabled identity map get stale after updates.

It goes like this:
1) Get object.
2) Update it.
3) save! it.
4) .find(id) returns old version, before update.
It happens with Mongoid 2.3.3

Code to reproduce:

```ruby
# connect to mongo
Mongoid.config.identity_map_enabled
# true

class Bong
include Mongoid::Document
include Mongoid::Versioning
field :session_cookie, type: String
index :session_cookie
end

Bong.create!(session_cookie: "111")
#

b = Bong.find('4eba2d2d530a691d13000001')
#
b.session_cookie = '222'
b.save!

b = Bong.find('4eba2d2d530a691d13000001')
#
b.session_cookie
"111"

b.versions
#[]
```