Commit e314d49e9976f3b0e22bb17f7bc4aee6e2d72105
1 parent
007ca5e7
Exists in
master
and in
27 other branches
rails3: fix count on paginated collections
will_paginate returns an ActiveRecord::Relation, so count will do a 'select count' in db. Use size instead. https://github.com/mislav/will_paginate/wiki/Backwards-incompatibility#willpaginatecollection
Showing
4 changed files
with
7 additions
and
7 deletions
Show diff stats
test/functional/catalog_controller_test.rb
| ... | ... | @@ -47,7 +47,7 @@ class CatalogControllerTest < ActionController::TestCase |
| 47 | 47 | |
| 48 | 48 | assert_equal 12, @enterprise.products.count |
| 49 | 49 | get :index, :profile => @enterprise.identifier |
| 50 | - assert_equal 9, assigns(:products).count | |
| 50 | + assert_equal 9, assigns(:products).size | |
| 51 | 51 | assert_tag :a, :attributes => {:class => 'next_page'} |
| 52 | 52 | end |
| 53 | 53 | ... | ... |
test/functional/manage_products_controller_test.rb
| ... | ... | @@ -361,7 +361,7 @@ class ManageProductsControllerTest < ActionController::TestCase |
| 361 | 361 | fast_create(Product, :name => "test product_#{n}", :enterprise_id => @enterprise.id, :product_category_id => @product_category.id) |
| 362 | 362 | end |
| 363 | 363 | get :index, :profile => @enterprise.identifier |
| 364 | - assert_equal 10, assigns(:products).count | |
| 364 | + assert_equal 10, assigns(:products).size | |
| 365 | 365 | end |
| 366 | 366 | |
| 367 | 367 | should 'paginate the manage products list of enterprise' do |
| ... | ... | @@ -373,7 +373,7 @@ class ManageProductsControllerTest < ActionController::TestCase |
| 373 | 373 | assert_tag :tag => 'a', :attributes => { :rel => 'next', :href => "/myprofile/#{@enterprise.identifier}/manage_products?page=2" } |
| 374 | 374 | |
| 375 | 375 | get :index, :profile => @enterprise.identifier, :page => 2 |
| 376 | - assert_equal 2, assigns(:products).count | |
| 376 | + assert_equal 2, assigns(:products).size | |
| 377 | 377 | end |
| 378 | 378 | |
| 379 | 379 | should 'display tabs even if description and inputs are empty and user is allowed' do | ... | ... |
test/functional/profile_controller_test.rb
| ... | ... | @@ -905,7 +905,7 @@ class ProfileControllerTest < ActionController::TestCase |
| 905 | 905 | community = fast_create(Community) |
| 906 | 906 | 40.times{ fast_create(ActionTrackerNotification, :profile_id => community.id, :action_tracker_id => fast_create(ActionTracker::Record, :user_id => profile.id)) } |
| 907 | 907 | get :index, :profile => community.identifier |
| 908 | - assert_equal 15, assigns(:network_activities).count | |
| 908 | + assert_equal 15, assigns(:network_activities).size | |
| 909 | 909 | end |
| 910 | 910 | |
| 911 | 911 | should 'the self activity not crashes with user not logged in' do |
| ... | ... | @@ -1162,7 +1162,7 @@ class ProfileControllerTest < ActionController::TestCase |
| 1162 | 1162 | get :view_more_network_activities, :profile => profile.identifier, :page => 2 |
| 1163 | 1163 | assert_response :success |
| 1164 | 1164 | assert_template '_profile_network_activities' |
| 1165 | - assert_equal 10, assigns(:activities).count | |
| 1165 | + assert_equal 10, assigns(:activities).size | |
| 1166 | 1166 | end |
| 1167 | 1167 | |
| 1168 | 1168 | should "be logged in to access the view_more_network_activities action" do | ... | ... |
test/functional/search_controller_test.rb
| ... | ... | @@ -520,7 +520,7 @@ class SearchControllerTest < ActionController::TestCase |
| 520 | 520 | |
| 521 | 521 | get :people |
| 522 | 522 | assert_equal SearchController::BLOCKS_SEARCH_LIMIT+3, Person.count |
| 523 | - assert_equal SearchController::BLOCKS_SEARCH_LIMIT, assigns(:searches)[:people][:results].count | |
| 523 | + assert_equal SearchController::BLOCKS_SEARCH_LIMIT, assigns(:searches)[:people][:results].size | |
| 524 | 524 | assert_tag :a, '', :attributes => {:class => 'next_page'} |
| 525 | 525 | end |
| 526 | 526 | |
| ... | ... | @@ -540,7 +540,7 @@ class SearchControllerTest < ActionController::TestCase |
| 540 | 540 | |
| 541 | 541 | get :communities |
| 542 | 542 | assert_equal SearchController::BLOCKS_SEARCH_LIMIT+3, Community.count |
| 543 | - assert_equal SearchController::BLOCKS_SEARCH_LIMIT, assigns(:searches)[:communities][:results].count | |
| 543 | + assert_equal SearchController::BLOCKS_SEARCH_LIMIT, assigns(:searches)[:communities][:results].size | |
| 544 | 544 | assert_tag :a, '', :attributes => {:class => 'next_page'} |
| 545 | 545 | end |
| 546 | 546 | ... | ... |