diff options
author | Jon Leighton <j@jonathanleighton.com> | 2010-12-16 00:40:03 +0000 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-15 17:47:42 -0800 |
commit | 09ddca67acbb88e2fdd7300670839cbf647b2694 (patch) | |
tree | c0be01dd066c966daaf76e35be91e41567f6cb96 /activerecord/test/cases/associations/has_many_through_associations_test.rb | |
parent | 6bfa846a2cc950bbb3d8b30f076589a60f38b821 (diff) | |
download | rails-09ddca67acbb88e2fdd7300670839cbf647b2694.tar.gz rails-09ddca67acbb88e2fdd7300670839cbf647b2694.tar.bz2 rails-09ddca67acbb88e2fdd7300670839cbf647b2694.zip |
Fix problem with duplicated records when a :uniq :through association is preloaded [#2447 state:resolved]
Diffstat (limited to 'activerecord/test/cases/associations/has_many_through_associations_test.rb')
-rw-r--r-- | activerecord/test/cases/associations/has_many_through_associations_test.rb | 8 |
1 files changed, 7 insertions, 1 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 44ff01ddc0..77bc369ecc 100644 --- a/activerecord/test/cases/associations/has_many_through_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb @@ -23,7 +23,7 @@ require 'models/category' class HasManyThroughAssociationsTest < ActiveRecord::TestCase fixtures :posts, :readers, :people, :comments, :authors, :owners, :pets, :toys, :jobs, :references, :companies, - :subscribers, :books, :subscriptions, :developers + :subscribers, :books, :subscriptions, :developers, :categorizations # Dummies to force column loads so query counts are clean. def setup @@ -473,4 +473,10 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase category = authors(:david).special_categories.create(:name => "Foo") assert_equal 1, category.categorizations.where(:special => true).count end + + def test_joining_has_many_through_with_uniq + mary = Author.joins(:unique_categorized_posts).where(:id => authors(:mary).id).first + assert_equal 1, mary.unique_categorized_posts.length + assert_equal 1, mary.unique_categorized_post_ids.length + end end |