Sha256: 09061f61342a0b08e4ca838912f7b86a1b294b7dc365b756d90414f52ae2e877

Contents?: true

Size: 815 Bytes

Versions: 4

Compression:

Stored size: 815 Bytes

Contents

require 'test_helper'

class RelationMiddleTest < ActiveSupport::TestCase

  setup do
    10.times.each { |index| Model.create name: index }
  end

  test "should have 5 pages" do
    assert_equal 5, relation.total_pages
  end

  test "current page should be 3" do
    assert_equal 3, relation.current_page
  end

  test "first page should be 1" do
    assert_equal 1, relation.first_page
  end

  test "should have previous page 2" do
    assert_equal 2, relation.previous_page
  end

  test "should have next page 4" do
    assert_equal 4, relation.next_page
  end
  
  test "last page shuold be 5" do
    assert_equal 5, relation.last_page
  end

  test "should not be out of bounds" do
    assert !relation.out_of_bounds?
  end

  protected

  def relation
    @relation ||= Model.page(3, length: 2)
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pagers-3.0.3 test/middle_test.rb
pagers-3.0.2 test/middle_test.rb
pagers-3.0.1 test/middle_test.rb
pagers-3.0.0 test/middle_test.rb