Permalink
Browse files

Test to verify that #2189 (count with has_many :through and a named_s…

…cope) is fixed [#2189 state:resolved]
  • Loading branch information...
1 parent bbb2252 commit 90f55bd93b409897e51a6533b0e3ed5fa284660f @jonleighton jonleighton committed Dec 22, 2010
@@ -17,11 +17,13 @@
require 'models/subscriber'
require 'models/book'
require 'models/subscription'
+require 'models/category'
+require 'models/categorization'
class HasManyThroughAssociationsTest < ActiveRecord::TestCase
- fixtures :posts, :readers, :people, :comments, :authors,
+ fixtures :posts, :readers, :people, :comments, :authors, :categories,
: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
@@ -456,4 +458,9 @@ def test_size_of_through_association_should_increase_correctly_when_has_many_ass
post.people << people(:michael)
assert_equal readers + 1, post.readers.size
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 @@ 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

0 comments on commit 90f55bd

Please sign in to comment.