diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-07-08 20:59:25 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-07-08 21:03:54 +0100 |
commit | dfec3737b05d22e6f298bcae0a8948a4b8803ebd (patch) | |
tree | a84c0a5ac3b23ece8eb51c1c1ac831ad5fb78193 /activerecord/test/cases/associations | |
parent | c1c886a0c44c8b13a4f23927d84eda74565eaca8 (diff) | |
download | rails-dfec3737b05d22e6f298bcae0a8948a4b8803ebd.tar.gz rails-dfec3737b05d22e6f298bcae0a8948a4b8803ebd.tar.bz2 rails-dfec3737b05d22e6f298bcae0a8948a4b8803ebd.zip |
Ensure that the foreign key gets set when doing record.create_association or record.create_association. Fixes #1960.
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r-- | activerecord/test/cases/associations/belongs_to_associations_test.rb | 14 |
1 files changed, 14 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 7338513b41..4190f6d76d 100644 --- a/activerecord/test/cases/associations/belongs_to_associations_test.rb +++ b/activerecord/test/cases/associations/belongs_to_associations_test.rb @@ -667,4 +667,18 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase firm = client.create_firm!{ |f| f.name = 'Agency Company' } assert_equal 'Agency Company', firm.name end + + def test_should_set_foreign_key_on_create_association + client = Client.create! :name => "fuu" + + firm = client.create_firm :name => "baa" + assert_equal firm.id, client.client_of + end + + def test_should_set_foreign_key_on_create_association! + client = Client.create! :name => "fuu" + + firm = client.create_firm! :name => "baa" + assert_equal firm.id, client.client_of + end end |