Ticket #9167: test_eager_with_conditional_properly_counts_the_records_stable.diff
| File test_eager_with_conditional_properly_counts_the_records_stable.diff, 2.3 kB (added by danger, 1 year ago) |
|---|
-
activerecord/test/associations/eager_test.rb
old new 271 271 assert_not_nil f.account 272 272 assert_equal companies(:first_firm, :reload).account, f.account 273 273 end 274 275 def test_eager_with_multi_table_conditional_properly_counts_the_records_when_using_size 276 author = authors(:david) 277 posts_with_no_comments = author.posts.select { |post| post.comments.blank? } 278 assert_equal posts_with_no_comments.size, author.posts_with_no_comments.size 279 assert_equal posts_with_no_comments, author.posts_with_no_comments 280 end 274 281 275 282 def test_eager_with_invalid_association_reference 276 283 assert_raises(ActiveRecord::ConfigurationError, "Association was not found; perhaps you misspelled it? You specified :include => :monkeys") { -
activerecord/test/fixtures/author.rb
old new 25 25 26 26 has_many :hello_posts, :class_name => "Post", :conditions => "posts.body = 'hello'" 27 27 has_many :hello_post_comments, :through => :hello_posts, :source => :comments 28 has_many :posts_with_no_comments, :class_name => 'Post', :conditions => 'comments.id is null', :include => :comments 28 29 29 30 has_many :other_posts, :class_name => "Post" 30 31 has_many :posts_with_callbacks, :class_name => "Post", :before_add => :log_before_adding, -
activerecord/lib/active_record/associations/has_many_association.rb
old new 138 138 elsif @reflection.options[:counter_sql] 139 139 @reflection.klass.count_by_sql(@counter_sql) 140 140 else 141 @reflection.klass.count(:conditions => @counter_sql )141 @reflection.klass.count(:conditions => @counter_sql, :include => @reflection.options[:include]) 142 142 end 143 143 144 144 @target = [] and loaded if count == 0