require File.dirname(__FILE__) + '/../test_helper' class CompanyTest < Test::Unit::TestCase fixtures :companies, :addresses, :people # Save a fixture? def test_sanity assert @acme.save end def test_must_have_name @acme.name = '' assert !@acme.save end def test_must_have_real_address_id @acme.address_id = 0 assert !@acme.save end def test_must_have_real_address @acme.address = @acme_hq assert @acme.save end # Test that the after_destroy call-back for Company # correctly triggers deletion of an orphaned address. def test_deletes_orphaned_address @acme.destroy assert_raise(ActiveRecord::RecordNotFound) { Address.find 1 } end # Test that the after_destroy call-back for Company # doesn't touch addresses still attached to a person. def test_doesnt_delete_address_still_associated_with_person @finnegans.destroy assert_nothing_raised(ActiveRecord::RecordNotFound) { Address.find 2 } end end