mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Test to verify that #2189 (count with has_many :through and a named_scope) is fixed
This commit is contained in:
committed by
Aaron Patterson
parent
1619c2435b
commit
3f17ed407c
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user