will_paginate icon indicating copy to clipboard operation
will_paginate copied to clipboard

ActiveRecord Relation size mismatch on last page when not loaded

Open hallelujah opened this issue 8 years ago • 0 comments

This can be added to spec/finders/active_record_spec.rb

  it 'returns correct `size` for last page' do
    users = User.paginate(:page => 3, :per_page => 5)
    users.total_entries.should == 13
    users.total_pages.should == 3

    users.size.should == 3
  end

The test is failing:

bundle exec rspec spec/finders/active_record_spec.rb:420                                                                                    [2.3]
using sqlite3 adapter
Run filtered including {:line_number=>420}
F

Failures:

  1) WillPaginate::ActiveRecord returns correct `size` for last page
     Failure/Error: users.size.should == 3
       expected: 3
            got: 5 (using ==)
     # ./spec/finders/active_record_spec.rb:425:in `block (2 levels) in <top (required)>'

Finished in 0.00122 seconds
1 example, 1 failure

Failed examples:

rspec ./spec/finders/active_record_spec.rb:420 # WillPaginate::ActiveRecord returns correct `size` for last page

hallelujah avatar Aug 04 '16 12:08 hallelujah