Sha256: bb8a5c5732c3262193552a3d3ebf15a6a47bc2dc433af2055d1d0fcbc1700712

Contents?: true

Size: 1.54 KB

Versions: 3

Compression:

Stored size: 1.54 KB

Contents

require 'test_helper'

class PaddingTest < ActiveSupport::TestCase
 
  test "negative padding should have 1 page" do
    19.times.each { |index| Model.create name: index }

    relation = Model.page(1, length: 15, padding: 4)
    assert_equal 15, relation.size
    assert_equal 1, relation.total_pages
 
    relation = Model.page(2, length: 15, padding: 4)
    assert_equal 0, relation.size
    assert_equal 1, relation.total_pages

    relation = Model.page(3, length: 15, padding: 4)
    assert_equal 0, relation.size
    assert_equal 1, relation.total_pages
  end

  test "negative padding should have 2 pages" do
    34.times.each { |index| Model.create name: index }
 
    relation = Model.page(1, length: 15, padding: 4)
    assert_equal 15, relation.size
    assert_equal 2, relation.total_pages

    relation = Model.page(2, length: 15, padding: 4)
    assert_equal 15, relation.size
    assert_equal 2, relation.total_pages
 
    relation = Model.page(3, length: 15, padding: 4)
    assert_equal 0, relation.size
    assert_equal 2, relation.total_pages
  end

  test "negative padding should have 3 pages" do
    49.times.each { |index| Model.create name: index }
 
    relation = Model.page(1, length: 15, padding: 4)
    assert_equal 15, relation.size
    assert_equal 3, relation.total_pages
 
    relation = Model.page(2, length: 15, padding: 4)
    assert_equal 15, relation.size
    assert_equal 3, relation.total_pages
 
    relation = Model.page(3, length: 15, padding: 4)
    assert_equal 15, relation.size
    assert_equal 3, relation.total_pages
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pagers-3.0.3 test/padding_test.rb
pagers-3.0.2 test/padding_test.rb
pagers-3.0.1 test/padding_test.rb