From 81b05fd9098c492bcf8651fe9042e5157d9a994b Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sat, 19 Aug 2006 09:13:00 +0000 Subject: 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 --- activerecord/test/associations_join_model_test.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'activerecord/test/associations_join_model_test.rb') 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 -- cgit v1.2.3