In Rails 4.2.1, I have a Book
model. I also have BookAcl
model that belongs_to
to Book
. In my test, I load both through fixtures defined in tests/fixtures
. In my test, in setup
, I instantiate both objects based on the fixture data. Up to this point everything works fine.
In my test, I modify the BookAcl object and expect these changes to be reflected when accessing the same BookAcl through the Book object. However that is not happening. In fact when I look (via Pry) at the BookAcl object, the properties are different than the Book.BookAcl object, even though the rest of the object is identical.
What am I doing wrong? How I force these changes to propagate through the object graph?
Call #reload
. There is no Identity Map in current version of Rails (they decided it produced too much bugs), so you should manually re-fetch all objects you wish by calling #reload
whenever DB record changes.