Problem destroying in unit tests with HABTM


#1

Hi converted two of my models to HABTM today but I am having a real
hard time getting my unit tests to pass now. Specifically, when I
destroy a record I get this error:

…many many lines of this above…
(eval):4:in destroy_without_habtm_shim_for_categories' (eval):4:indestroy_without_habtm_shim_for_categories’
(eval):4:in destroy_without_habtm_shim_for_categories' (eval):4:indestroy_without_habtm_shim_for_categories’
(eval):4:in destroy_without_habtm_shim_for_categories' (eval):4:indestroy_without_habtm_shim_for_categories’
(eval):4:in destroy_without_habtm_shim_for_categories' (eval):4:indestroy_without_habtm_shim_for_categories’
(eval):4:in destroy_without_habtm_shim_for_categories' (eval):4:indestroy_without_callbacks’
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.1/lib/active_record/callbacks.rb:321:in
destroy_witho c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.1/lib/active_record/transactions.rb:122:indestroy’
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.1/lib/active_record/transactions.rb:122:in
transactio c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.1/lib/active_record/transactions.rb:91:intransaction
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.1/lib/active_record/transactions.rb:118:in
transactio c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.1/lib/active_record/transactions.rb:122:indestroy’

I have a category table an asset table and an assets_categories table

My destroy unit tests looks like this:

def test_destroy
#check to ensure asset belongs to categories
assert_equal false, @intl_image.categories.empty?
@intl_image.categories.clear
#check to ensure the asset now belongs to no categories
assert_equal true, @intl_image.categories.empty?
@intl_image.save
@intl_image.reload
@img = Asset.find(@intl_image.id)
@img.destroy

assert_raise(ActiveRecord::RecordNotFound){Asset.find(@intl_image.id)}
end

Any help is greatly appreciated.
Thanks,
Mark