Permalink
Browse files

Failing test for aggregating on default_scope with select

  • Loading branch information...
1 parent dfaad4f commit a5806fa409ff286e86eb9fabcee25d083892606f @Fonsan Fonsan committed with jonleighton May 29, 2011
Showing with 9 additions and 0 deletions.
  1. +4 −0 activerecord/test/cases/relation_scoping_test.rb
  2. +5 −0 activerecord/test/models/developer.rb
View
4 activerecord/test/cases/relation_scoping_test.rb
@@ -471,6 +471,10 @@ def test_unscoped_with_named_scope_should_not_have_default_scope
assert_equal 10, DeveloperCalledJamis.unscoped.poor.length
end
+ def test_default_scope_select_ignored_by_aggregations
+ assert_equal DeveloperWithSelect.all.count, DeveloperWithSelect.count
+ end
+
def test_default_scope_order_ignored_by_aggregations
assert_equal DeveloperOrderedBySalary.all.count, DeveloperOrderedBySalary.count
end
View
5 activerecord/test/models/developer.rb
@@ -86,6 +86,11 @@ def raise_if_projects_empty!
end
end
+class DeveloperWithSelect < ActiveRecord::Base
+ self.table_name = 'developers'
+ default_scope select('name')
+end
+
class DeveloperOrderedBySalary < ActiveRecord::Base
self.table_name = 'developers'
default_scope :order => 'salary DESC'

0 comments on commit a5806fa

Please sign in to comment.