diff options
author | Jon Leighton <j@jonathanleighton.com> | 2008-09-07 14:42:33 +0100 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2008-09-13 11:08:29 +0200 |
commit | fcf31cb7521ba7de0aae972ac2ddfc80e3e7dfce (patch) | |
tree | b01347616c463b6c51f8761e0d9d400c1e775300 /activerecord/test/cases/associations | |
parent | 646b5bfa61f8e803d98bd1557c53ea961cc6b16d (diff) | |
download | rails-fcf31cb7521ba7de0aae972ac2ddfc80e3e7dfce.tar.gz rails-fcf31cb7521ba7de0aae972ac2ddfc80e3e7dfce.tar.bz2 rails-fcf31cb7521ba7de0aae972ac2ddfc80e3e7dfce.zip |
Support for updating a belongs to association from the foreign key (without saving and reloading the record)
Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#142 state:committed]
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r-- | activerecord/test/cases/associations/belongs_to_associations_test.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/belongs_to_associations_test.rb b/activerecord/test/cases/associations/belongs_to_associations_test.rb index 9c718c4fef..37b6836a89 100644 --- a/activerecord/test/cases/associations/belongs_to_associations_test.rb +++ b/activerecord/test/cases/associations/belongs_to_associations_test.rb @@ -47,6 +47,19 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase assert_equal apple.id, citibank.firm_id end + def test_foreign_key_assignment + # Test using an existing record + signals37 = accounts(:signals37) + assert_equal companies(:first_firm), signals37.firm + signals37.firm_id = companies(:another_firm).id + assert_equal companies(:another_firm), signals37.firm + + # Test using a new record + account = Account.new + account.firm_id = companies(:another_firm).id + assert_equal companies(:another_firm), account.firm + end + def test_no_unexpected_aliasing first_firm = companies(:first_firm) another_firm = companies(:another_firm) |