I am creating an object with several has_many associations. Everything with regards tob building the object works fine, but when I try to test the deletion of one of the children or parent, it does not reflect in the test.
For example:
base_article = Factory(:base_article, :articles => [Factory(:article)])
p base_article.articles.size
base_article.articles.first.destroy
p base_article.articles.size
base_article.destroyed?.should == true
This prints out:
1
1
I am testing the callback after destroy on the article that deletes the base when there are no more children. Why is the size of the articles association not being reduced by one?
Thanks!
You need to reload the articles collection as Rails’ database caching is stale: