I have in project.rb:
has_many :items, :dependent => :destroy
And in item.rb:
belongs_to :project
My projects fixture:
b1_s_first_project:
title: B1's first project
And my items fixture:
b1_s_first_project_s_first_item:
title: B1's first project's first item
project: b1_s_first_project
In my unit test, I set local variables item = items(:b1_s_first_project_s_first_item)
and project = projects(:b1_s_first_project)
. When I call project.destroy
, project.destroyed?
returns true, but item.destroyed?
returns nil, as if it hadn't been destroyed. What am I missing? Thanks in advance.
It looks like you might need to add item.reload
before testing if it's destroyed or not
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With