diff options
author | Dimitri Krassovski <labria@startika.com> | 2009-03-06 19:11:13 +0000 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-03-06 19:11:13 +0000 |
commit | 984bc7a614852944808739fae09a654b6e62872e (patch) | |
tree | e5eede0f31d0b9cd8708c506fe81c12fe3f195df /activerecord/test/cases/associations/has_one_associations_test.rb | |
parent | 4863634a157a8e4a0033734617253b42325daf34 (diff) | |
download | rails-984bc7a614852944808739fae09a654b6e62872e.tar.gz rails-984bc7a614852944808739fae09a654b6e62872e.tar.bz2 rails-984bc7a614852944808739fae09a654b6e62872e.zip |
Ensure replacing has_one associations respects the supplied :dependent option. [#1305 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Diffstat (limited to 'activerecord/test/cases/associations/has_one_associations_test.rb')
-rw-r--r-- | activerecord/test/cases/associations/has_one_associations_test.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_one_associations_test.rb b/activerecord/test/cases/associations/has_one_associations_test.rb index e81bba790a..0aafbcee36 100644 --- a/activerecord/test/cases/associations/has_one_associations_test.rb +++ b/activerecord/test/cases/associations/has_one_associations_test.rb @@ -79,6 +79,24 @@ class HasOneAssociationsTest < ActiveRecord::TestCase assert_raises(ActiveRecord::RecordNotFound) { Account.find(old_account_id) } end + def test_nullification_on_association_change + firm = companies(:rails_core) + old_account_id = firm.account.id + firm.account = Account.new + # account is dependent with nullify, therefore its firm_id should be nil + assert_nil Account.find(old_account_id).firm_id + end + + def test_association_changecalls_delete + companies(:first_firm).deletable_account = Account.new + assert_equal [], Account.destroyed_account_ids[companies(:first_firm).id] + end + + def test_association_change_calls_destroy + companies(:first_firm).account = Account.new + assert_equal [companies(:first_firm).id], Account.destroyed_account_ids[companies(:first_firm).id] + end + def test_natural_assignment_to_already_associated_record company = companies(:first_firm) account = accounts(:signals37) |