aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations
diff options
context:
space:
mode:
authorJon Rowe <hello@jonrowe.co.uk>2012-03-15 18:27:43 +0000
committerJon Rowe <hello@jonrowe.co.uk>2012-03-15 19:18:31 +0000
commitf31670d0270342f37846082ac1a27fc6d3400a8a (patch)
tree060604c109ef1fb91a248f707c6c2b0ecf9e3799 /activerecord/test/cases/associations
parentfbc9d0f44f090a9873834f4966760c3e80682559 (diff)
downloadrails-f31670d0270342f37846082ac1a27fc6d3400a8a.tar.gz
rails-f31670d0270342f37846082ac1a27fc6d3400a8a.tar.bz2
rails-f31670d0270342f37846082ac1a27fc6d3400a8a.zip
when using a preloaded array and the uniq flag is set then return the size of the uniq array
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r--activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
index f457dfb9b3..2fa2c6d13f 100644
--- a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
@@ -338,6 +338,12 @@ class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase
assert_equal 3, project.developers.size
end
+ def test_uniq_when_association_already_loaded
+ project = projects(:active_record)
+ project.developers << [ developers(:jamis), developers(:david), developers(:jamis), developers(:david) ]
+ assert_equal 3, Project.includes(:developers).find(project.id).developers.size
+ end
+
def test_deleting
david = Developer.find(1)
active_record = Project.find(1)