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 a244d310c86aca44491fcd6782d32eaacde74b19..a417345780fa02ea6d12668ca832530a56ecc617 100644 --- a/activerecord/test/cases/associations/has_many_through_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb @@ -529,4 +529,9 @@ def test_select_chosen_fields_only 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 diff --git a/activerecord/test/models/category.rb b/activerecord/test/models/category.rb index 48415846dd367297d960f842992ddda78b245b14..06908ea85e2f82ef8f2d719382275b7ef075cd96 100644 --- a/activerecord/test/models/category.rb +++ b/activerecord/test/models/category.rb @@ -23,6 +23,8 @@ def self.what_are_you has_many :categorizations has_many :authors, :through => :categorizations, :select => 'authors.*, categorizations.post_id' + + scope :general, :conditions => { :name => 'General' } end class SpecialCategory < Category