From 5cee1734da7725a088a7428347e2439c05ee8253 Mon Sep 17 00:00:00 2001 From: Kostiantyn Kahanskyi Date: Mon, 6 Jun 2011 12:51:02 +0200 Subject: [PATCH] Should always include docs when paginating by Model##paginate Fixes https://github.com/couchrest/couchrest_model/issues/81 --- lib/couchrest/model/collection.rb | 1 + spec/couchrest/collection_spec.rb | 13 ++++++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/couchrest/model/collection.rb b/lib/couchrest/model/collection.rb index 540b299..5d6dd76 100644 --- a/lib/couchrest/model/collection.rb +++ b/lib/couchrest/model/collection.rb @@ -244,6 +244,7 @@ module CouchRest else options = { :limit => per_page, :skip => per_page * (page - 1) } end + options[:include_docs] = true view_options.merge(options) end diff --git a/spec/couchrest/collection_spec.rb b/spec/couchrest/collection_spec.rb index 528a350..63a1626 100644 --- a/spec/couchrest/collection_spec.rb +++ b/spec/couchrest/collection_spec.rb @@ -27,21 +27,20 @@ describe "Collections" do end it "should provide a class method for paginate" do articles = Article.paginate(:design_doc => 'Article', :view_name => 'by_date', - :per_page => 3, :descending => true, :key => Date.today, :include_docs => true) + :per_page => 3, :descending => true, :key => Date.today) articles.size.should == 3 - + articles = Article.paginate(:design_doc => 'Article', :view_name => 'by_date', - :per_page => 3, :page => 2, :descending => true, :key => Date.today, :include_docs => true) + :per_page => 3, :page => 2, :descending => true, :key => Date.today) articles.size.should == 3 - + articles = Article.paginate(:design_doc => 'Article', :view_name => 'by_date', - :per_page => 3, :page => 3, :descending => true, :key => Date.today, :include_docs => true) + :per_page => 3, :page => 3, :descending => true, :key => Date.today) articles.size.should == 1 end it "should provide a class method for paginated_each" do options = { :design_doc => 'Article', :view_name => 'by_date', - :per_page => 3, :page => 1, :descending => true, :key => Date.today, - :include_docs => true } + :per_page => 3, :page => 1, :descending => true, :key => Date.today } Article.paginated_each(options) do |a| a.should_not be_nil end