Sha256: 9f667af5bdb2b4cb51b2975ef83716254ef13f4c4f4935b13207aac4a539662a

Contents?: true

Size: 658 Bytes

Versions: 1

Compression:

Stored size: 658 Bytes

Contents

require "spec_helper"

describe Thing do
  let!(:things) { Array.new(15) {|i| Thing.create!(name: "THING") } }
  before { Paginate.configuration.size = 10 }

  it { expect(Thing).to respond_to(:paginate) }

  it "uses default options" do
    items = Thing.limit(11).to_a
    expect(Thing.paginate.to_a).to eql(items)

    items = Thing.limit(11).offset(10).to_a
    expect(Thing.paginate(page: 2).to_a).to eql(items)
  end

  it "uses custom options" do
    items = Thing.limit(6).to_a
    expect(Thing.paginate(size: 5).to_a).to eql(items)

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
paginate-4.0.0 spec/paginate/activerecord_spec.rb