From 377bdd02b9daba35113299262a98060763925959 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 20 Feb 2006 03:15:22 +0000 Subject: Added :count option to pagination that'll make it possible for the ActiveRecord::Base.count call to using something else than * for the count. Especially important for count queries using DISTINCT #3839 [skaes]. Added :select option to Base.count that'll allow you to select something else than * to be counted on. Especially important for count queries using DISTINCT (closes #3839) [skaes]. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3620 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/test/activerecord/pagination_test.rb | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'actionpack/test/activerecord/pagination_test.rb') diff --git a/actionpack/test/activerecord/pagination_test.rb b/actionpack/test/activerecord/pagination_test.rb index 00ae78614f..386300c086 100644 --- a/actionpack/test/activerecord/pagination_test.rb +++ b/actionpack/test/activerecord/pagination_test.rb @@ -64,6 +64,14 @@ class PaginationTest < ActiveRecordTestCase :conditions => 'project_id=1') render :nothing => true end + + def paginate_with_join_and_count + @developer_pages, @developers = paginate(:developers, + :join => 'd LEFT JOIN developers_projects ON d.id = developers_projects.developer_id', + :conditions => 'project_id=1', + :count => "d.id") + render :nothing => true + end def rescue_errors(e) raise e end @@ -133,9 +141,16 @@ class PaginationTest < ActiveRecordTestCase def test_paginate_with_join_and_conditions get :paginate_with_joins - expected = assigns(:topics) + expected = assigns(:developers) get :paginate_with_join - assert_equal expected, assigns(:topics) + assert_equal expected, assigns(:developers) + end + + def test_paginate_with_join_and_count + get :paginate_with_joins + expected = assigns(:developers) + get :paginate_with_join_and_count + assert_equal expected, assigns(:developers) end def test_paginate_with_include_and_order -- cgit v1.2.3