Merge pull request #88 from kostia/incl_docs_paginate

Should always include docs when paginating by Model##paginate
This commit is contained in:
Sam Lown 2011-06-06 04:19:44 -07:00
commit a55cf56213
2 changed files with 7 additions and 7 deletions

View file

@ -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

View file

@ -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