Sha256: 250bef9242e405e76808fd6d6a762d8f28426d83e10646b297101461de836960

Contents?: true

Size: 726 Bytes

Versions: 1

Compression:

Stored size: 726 Bytes

Contents

require "test_helper"

class ActiverecordTest < Minitest::Test
  let(:things) { Array.new(15) {|i| Thing.create!(name: "THING") } }

  setup do
    things
    Paginate.configuration.size = 10
  end

  test "responds to paginate" do
    assert Thing.respond_to?(:paginate)
  end

  test "uses default options" do
    items = Thing.limit(11).to_a
    assert_equal items, Thing.paginate.to_a

    items = Thing.limit(11).offset(10).to_a
    assert_equal items, Thing.paginate(page: 2).to_a
  end

  test "uses custom options" do
    items = Thing.limit(6).to_a
    assert_equal items, Thing.paginate(size: 5).to_a

    items = Thing.limit(6).offset(5).to_a
    assert_equal items, Thing.paginate(size: 5, page: 2).to_a
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
paginate-4.0.1 test/paginate/activerecord_test.rb