diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-05-22 03:39:36 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-05-22 03:39:36 +0000 |
commit | 4afd6c9f0a0e97429191af3e3b348ffa4416c640 (patch) | |
tree | af0288db836a551e1d1d06b4b3b5d22f6e6b48bf /activerecord/test | |
parent | 8ba22a690c65009d0f64e32cd316bc1ca45492c7 (diff) | |
download | rails-4afd6c9f0a0e97429191af3e3b348ffa4416c640.tar.gz rails-4afd6c9f0a0e97429191af3e3b348ffa4416c640.tar.bz2 rails-4afd6c9f0a0e97429191af3e3b348ffa4416c640.zip |
belongs_to assignment creates a new proxy rather than modifying its target in-place. Closes #8412.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6804 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rwxr-xr-x | activerecord/test/associations_test.rb | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/activerecord/test/associations_test.rb b/activerecord/test/associations_test.rb index 8f60fc95f1..03c344de7c 100755 --- a/activerecord/test/associations_test.rb +++ b/activerecord/test/associations_test.rb @@ -1039,7 +1039,20 @@ class BelongsToAssociationsTest < Test::Unit::TestCase citibank.firm = apple assert_equal apple.id, citibank.firm_id end - + + def test_no_unexpected_aliasing + first_firm = companies(:first_firm) + another_firm = companies(:another_firm) + + citibank = Account.create("credit_limit" => 10) + citibank.firm = first_firm + original_proxy = citibank.firm + citibank.firm = another_firm + + assert_equal first_firm.object_id, original_proxy.object_id + assert_equal another_firm.object_id, citibank.firm.object_id + end + def test_creating_the_belonging_object citibank = Account.create("credit_limit" => 10) apple = citibank.create_firm("name" => "Apple") |