Sha256: b3e33cbb0071d4d1e199ac227f6c86f7f82161d440bac8ea95ed94a585febbbe

Contents?: true

Size: 781 Bytes

Versions: 1

Compression:

Stored size: 781 Bytes

Contents

require 'test_helper'

class RelationMiddleTest < ActiveSupport::TestCase

  setup do
    10.times.each { |index| Model.create name: index }
    @relation = Model.page(3).per(2)
  end

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

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

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

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

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

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

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pageable-2.1.0 test/middle_test.rb