diff options
author | Jon Leighton <j@jonathanleighton.com> | 2010-12-22 00:19:59 +0000 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-23 15:19:17 -0800 |
commit | ff7bde62c857ec94f45a5be3bc76468deb8b0b3a (patch) | |
tree | 64bb289a46f3de6216748aae5b1d2fd2d253f8a6 /activerecord/test/cases | |
parent | 030480ac1f4fbf8bf74a0d9298544426caf26894 (diff) | |
download | rails-ff7bde62c857ec94f45a5be3bc76468deb8b0b3a.tar.gz rails-ff7bde62c857ec94f45a5be3bc76468deb8b0b3a.tar.bz2 rails-ff7bde62c857ec94f45a5be3bc76468deb8b0b3a.zip |
When a has_many association is not :uniq, appending the same record multiple times should append it to the @target multiple times [#5964 state:resolved]
Diffstat (limited to 'activerecord/test/cases')
-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 6b71e73718..dfb3292502 100644 --- a/activerecord/test/cases/associations/has_many_through_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb @@ -45,6 +45,16 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase assert posts(:thinking).reload.people(true).include?(people(:david)) end + def test_associate_existing_record_twice_should_add_to_target_twice + post = posts(:thinking) + person = people(:david) + + assert_difference 'post.people.to_a.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 |