Test to verify that #2189 (count with has_many :through and a named_scope) is fixed

This commit is contained in:
Jon Leighton
2010-12-22 11:45:37 +00:00
committed by Aaron Patterson
parent 1619c2435b
commit 3f17ed407c
2 changed files with 7 additions and 0 deletions

View File

@@ -529,4 +529,9 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase
def test_get_has_many_through_belongs_to_ids_with_conditions
assert_equal [categories(:general).id], authors(:mary).categories_like_general_ids
end
def test_count_has_many_through_with_named_scope
assert_equal 2, authors(:mary).categories.count
assert_equal 1, authors(:mary).categories.general.count
end
end

View File

@@ -23,6 +23,8 @@ class Category < ActiveRecord::Base
has_many :categorizations
has_many :authors, :through => :categorizations, :select => 'authors.*, categorizations.post_id'
scope :general, :conditions => { :name => 'General' }
end
class SpecialCategory < Category