mongoid/mongoid — pull request #2943 by Exoth (2013-04-04 17:46:41+00:00)
Title: Fixed has_one excessive query.

It really fixes https://github.com/mongoid/mongoid/issues/2701

The problem is that there seems to be no way for a has_one setter to know, whether assigned object is the same without actually getting the object from DB; so I reversed your path and solved the problem in belongs_to setter. I'm not sure that I did it the best way, but at least I didn't break any existing specs and added one spec to cover the bug.