diff options
author | Jon Leighton <j@jonathanleighton.com> | 2010-12-22 11:45:37 +0000 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-23 15:19:18 -0800 |
commit | 3f17ed407c5d61bc01fd59776205486c2350f36e (patch) | |
tree | f88e42eb305473bd6c84fb4216908ca443830fc3 /activerecord | |
parent | 1619c2435b2b9c821b2b0dcab9624dbb6b23eaaa (diff) | |
download | rails-3f17ed407c5d61bc01fd59776205486c2350f36e.tar.gz rails-3f17ed407c5d61bc01fd59776205486c2350f36e.tar.bz2 rails-3f17ed407c5d61bc01fd59776205486c2350f36e.zip |
Test to verify that #2189 (count with has_many :through and a named_scope) is fixed
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/test/cases/associations/has_many_through_associations_test.rb | 5 | ||||
-rw-r--r-- | activerecord/test/models/category.rb | 2 |
2 files changed, 7 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 a244d310c8..a417345780 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 @@ 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 diff --git a/activerecord/test/models/category.rb b/activerecord/test/models/category.rb index 48415846dd..06908ea85e 100644 --- a/activerecord/test/models/category.rb +++ b/activerecord/test/models/category.rb @@ -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 |