Permalink
Browse files

Add failing spec for issue #101 using will_paginate

  • Loading branch information...
1 parent 39dd203 commit 165fc64a43acdf0877155f0fd51b5cafade04e8c @nertzy nertzy committed Apr 4, 2013
Showing with 37 additions and 0 deletions.
  1. +1 −0 pg_search.gemspec
  2. +36 −0 spec/integration/pagination_spec.rb
View
@@ -26,4 +26,5 @@ Gem::Specification.new do |s|
s.add_development_dependency 'pry'
s.add_development_dependency 'rspec'
s.add_development_dependency 'with_model'
+ s.add_development_dependency 'will_paginate'
end
@@ -0,0 +1,36 @@
+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

0 comments on commit 165fc64

Please sign in to comment.