diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2006-08-19 09:13:00 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2006-08-19 09:13:00 +0000 |
commit | 81b05fd9098c492bcf8651fe9042e5157d9a994b (patch) | |
tree | bb8328358e9be72e8cbb3edbba69a3f50c1170ee /activerecord/test | |
parent | a752fdb321d116c1f4fa0a61bd5d633575f0b09c (diff) | |
download | rails-81b05fd9098c492bcf8651fe9042e5157d9a994b.tar.gz rails-81b05fd9098c492bcf8651fe9042e5157d9a994b.tar.bz2 rails-81b05fd9098c492bcf8651fe9042e5157d9a994b.zip |
Pushing a record onto a has_many :through sets the association's foreign key to the associate's primary key. Closes #5815.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4790 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/associations_join_model_test.rb | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/activerecord/test/associations_join_model_test.rb b/activerecord/test/associations_join_model_test.rb index 508628f37a..0f6a5e76c2 100644 --- a/activerecord/test/associations_join_model_test.rb +++ b/activerecord/test/associations_join_model_test.rb @@ -370,15 +370,16 @@ class AssociationsJoinModelTest < Test::Unit::TestCase end def test_create_associate_when_adding_to_has_many_through - count = Tagging.count - assert_nothing_raised { posts(:thinking).tags << tags(:general) } - assert_equal(count + 1, Tagging.count) + count = posts(:thinking).tags.count + push = Tag.create!(:name => 'pushme') + assert_nothing_raised { posts(:thinking).tags << push } + assert_equal(count + 1, posts(:thinking).tags(true).size) assert_nothing_raised { posts(:thinking).tags.create!(:name => 'foo') } - assert_equal(count + 2, Tagging.count) + assert_equal(count + 2, posts(:thinking).tags(true).size) assert_nothing_raised { posts(:thinking).tags.concat(Tag.create!(:name => 'abc'), Tag.create!(:name => 'def')) } - assert_equal(count + 4, Tagging.count) + assert_equal(count + 4, posts(:thinking).tags(true).size) end def test_has_many_through_sum_uses_calculations |