Merge pull request #88 from kostia/incl_docs_paginate
Should always include docs when paginating by Model##paginate
This commit is contained in:
commit
a55cf56213
|
@ -244,6 +244,7 @@ module CouchRest
|
||||||
else
|
else
|
||||||
options = { :limit => per_page, :skip => per_page * (page - 1) }
|
options = { :limit => per_page, :skip => per_page * (page - 1) }
|
||||||
end
|
end
|
||||||
|
options[:include_docs] = true
|
||||||
view_options.merge(options)
|
view_options.merge(options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -27,21 +27,20 @@ describe "Collections" do
|
||||||
end
|
end
|
||||||
it "should provide a class method for paginate" do
|
it "should provide a class method for paginate" do
|
||||||
articles = Article.paginate(:design_doc => 'Article', :view_name => 'by_date',
|
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.size.should == 3
|
||||||
|
|
||||||
articles = Article.paginate(:design_doc => 'Article', :view_name => 'by_date',
|
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.size.should == 3
|
||||||
|
|
||||||
articles = Article.paginate(:design_doc => 'Article', :view_name => 'by_date',
|
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
|
articles.size.should == 1
|
||||||
end
|
end
|
||||||
it "should provide a class method for paginated_each" do
|
it "should provide a class method for paginated_each" do
|
||||||
options = { :design_doc => 'Article', :view_name => 'by_date',
|
options = { :design_doc => 'Article', :view_name => 'by_date',
|
||||||
:per_page => 3, :page => 1, :descending => true, :key => Date.today,
|
:per_page => 3, :page => 1, :descending => true, :key => Date.today }
|
||||||
:include_docs => true }
|
|
||||||
Article.paginated_each(options) do |a|
|
Article.paginated_each(options) do |a|
|
||||||
a.should_not be_nil
|
a.should_not be_nil
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue