Sha256: 252e9903c194a3e8032dd88c628446c710eea3ecfc56e2351502509e91073169

Contents?: true

Size: 1.09 KB

Versions: 5

Compression:

Stored size: 1.09 KB

Contents

require "spec_helper"

describe "pagination" do
  describe "with will_paginate" do
    require 'will_paginate/active_record'
    with_model :PaginatedModel do
      table do |t|
        t.string :name
      end

      model do
        include PgSearch
        self.per_page = 2
        pg_search_scope :search_name, :against => :name
      end
    end

    it "is chainable before a search scope" do
      better = PaginatedModel.create!(:name => "foo foo bar")
      best = PaginatedModel.create!(:name => "foo foo foo")
      good = PaginatedModel.create!(:name => "foo bar bar")

      PaginatedModel.page(1).search_name("foo").should == [best, better]
      PaginatedModel.page(2).search_name("foo").should == [good]
    end

    it "is chainable after a search scope" do
      better = PaginatedModel.create!(:name => "foo foo bar")
      best = PaginatedModel.create!(:name => "foo foo foo")
      good = PaginatedModel.create!(:name => "foo bar bar")

      PaginatedModel.search_name("foo").page(1).should == [best, better]
      PaginatedModel.search_name("foo").page(2).should == [good]
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pg_search-0.7.0 spec/integration/pagination_spec.rb
pg_search-0.6.4 spec/integration/pagination_spec.rb
pg_search-0.6.3 spec/integration/pagination_spec.rb
pg_search-0.6.2 spec/integration/pagination_spec.rb
pg_search-0.6.1 spec/integration/pagination_spec.rb