diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-11-03 12:37:37 +0000 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-11-03 12:39:05 +0000 |
commit | 71bc921ec8ac89840077bb54752282a3d89429f6 (patch) | |
tree | a98c3ed35ade80654a905d2db1cf1cdb45bee68a /activerecord/test/cases/associations | |
parent | b4b178f7e9a00a0235574a773cdbc06fe856acaf (diff) | |
download | rails-71bc921ec8ac89840077bb54752282a3d89429f6.tar.gz rails-71bc921ec8ac89840077bb54752282a3d89429f6.tar.bz2 rails-71bc921ec8ac89840077bb54752282a3d89429f6.zip |
Fix adding multiple instances of the same record to a has_many :through.
Fixes #3425.
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r-- | activerecord/test/cases/associations/has_many_through_associations_test.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_many_through_associations_test.rb b/activerecord/test/cases/associations/has_many_through_associations_test.rb index 2f4dd9e55c..115e06144e 100644 --- a/activerecord/test/cases/associations/has_many_through_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb @@ -67,6 +67,16 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase end end + def test_associate_existing_record_twice_should_add_records_twice + post = posts(:thinking) + person = people(:david) + + assert_difference 'post.people.count', 2 do + post.people << person + post.people << person + end + end + def test_associating_new assert_queries(1) { posts(:thinking) } new_person = nil # so block binding catches it |