diff options
author | Graeme Porteous <graeme@rgbp.co.uk> | 2009-07-11 20:04:18 +0200 |
---|---|---|
committer | Eloy Duran <eloy.de.enige@gmail.com> | 2009-09-12 16:03:32 +0200 |
commit | c01be9de322ba846923340e41e69821d01541610 (patch) | |
tree | e73d2aea62c53df7d1373f011ecfcd9abb70ae43 /activerecord/test/cases/associations | |
parent | 3091252abaafd15bc085f0be2b17829bebb6522c (diff) | |
download | rails-c01be9de322ba846923340e41e69821d01541610.tar.gz rails-c01be9de322ba846923340e41e69821d01541610.tar.bz2 rails-c01be9de322ba846923340e41e69821d01541610.zip |
Fix has_one with foreign_key and primary_key association bug which caused the associated object being lost when saving the owner. [#1756 state:resolved]
Mixed in a bit from patch by ransom-briggs. [#2813 state:resolved]
Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com>
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r-- | activerecord/test/cases/associations/has_one_associations_test.rb | 9 |
1 files changed, 9 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 7140de77ea..cdac86a3b9 100644 --- a/activerecord/test/cases/associations/has_one_associations_test.rb +++ b/activerecord/test/cases/associations/has_one_associations_test.rb @@ -36,6 +36,15 @@ class HasOneAssociationsTest < ActiveRecord::TestCase assert_equal accounts(:rails_core_account), firm.account_using_primary_key end + def test_update_with_foreign_and_primary_keys + firm = companies(:first_firm) + account = firm.account_using_foreign_and_primary_keys + assert_equal Account.find_by_firm_name(firm.name), account + firm.save + firm.reload + assert_equal account, firm.account_using_foreign_and_primary_keys + end + def test_can_marshal_has_one_association_with_nil_target firm = Firm.new assert_nothing_raised do |