# Test on destroy fails after 3.0.5 upgrade

**URL:** <https://www.ruby-forum.com/t/test-on-destroy-fails-after-3-0-5-upgrade/204861>\
**Category:** Rails\
**Created:** [March 23, 2011, 3:20pm UTC](https://www.ruby-forum.com/t/test-on-destroy-fails-after-3-0-5-upgrade/204861 "2011-03-23T15:20:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [March 23, 2011, 3:20pm UTC](https://www.ruby-forum.com/t/test-on-destroy-fails-after-3-0-5-upgrade/204861/1 "2011-03-23T15:20:44Z")

</div>

After upgrading 3.0.4 -\> 3.0.5 one of my tests now fails on an  
assertion like ‘assert !@product.destroy’.

This tests a :before\_destroy callback which simply returns false to  
prevent deletion. I verified that the callback is firing and haven’t  
been able to locate a difference between what’s returned in the 3.0.4  
and 3.0.5 source code. A console session shows destroyed? returning  
false as expected.

Has this happened to anybody else? It’s a simple test so I’d expect  
others to have the same result if there’s an actual problem.  
Lighthouse shows a recent issue with before\_destroy but it appears  
unrelated.

---

<div class="post-metadata">

**Author:** ![djangst](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ce73a5/32.png) [@djangst](https://www.ruby-forum.com/u/djangst)\
**Post date:** [March 23, 2011, 6:44pm UTC](https://www.ruby-forum.com/t/test-on-destroy-fails-after-3-0-5-upgrade/204861/2 "2011-03-23T18:44:18Z")

</div>

Hey Fred,

The model in question does have a HABTM association, but based on  
reading the ticket I thought it was unrelated because I don’t have a  
dependent destroy set up and am only operating on the parent. Maybe  
not.

I had looked at the new and old versions of destroy() but it appeared  
they were returning the same value.

destroy() calls freeze(). In a console session with a sample object  
frozen? returns false with my callback enabled, and true with it  
commented out, so that appears to be working.

I guess I’d need to set up 3.0.4 again and check the output to see if  
it was returning a different (falsy) value…

On Mar 23, 11:26am, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![djangst](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ce73a5/32.png) [@djangst](https://www.ruby-forum.com/u/djangst)\
**Post date:** [March 23, 2011, 4:39pm UTC](https://www.ruby-forum.com/t/test-on-destroy-fails-after-3-0-5-upgrade/204861/3 "2011-03-23T16:39:06Z")

</div>

On Mar 23, 2:19pm, djangst [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> others to have the same result if there’s an actual problem.  
> Lighthouse shows a recent issue with before\_destroy but it appears  
> unrelated.

Is this using a habtm association? There was a change to how destroy  
happens with those (which I personally think is broken) to do with  
when the before\_destroy callbacks run relative to the clearing out of  
associated rows. It looks to me like a side effect of that change  
could be that the return value of destroy could change

Fred
