added the Model.all view

This commit is contained in:
Chris Anderson 2008-10-02 23:36:39 -07:00
parent 355d408730
commit 26059f63f2
2 changed files with 7 additions and 4 deletions

View file

@ -93,6 +93,10 @@ module CouchRest
end
def all opts = {}
self.generated_design_doc ||= default_design_doc
unless design_doc_fresh
refresh_design_doc
end
view_name = "#{design_doc_slug}/all"
raw = opts.delete(:raw)
view = fetch_view(view_name, opts)

View file

@ -187,12 +187,11 @@ describe CouchRest::Model do
end
it "should make the design doc" do
WithTemplate.all
puts d = WithTemplate.design_doc.to_json
d.should == 'xs'
d = WithTemplate.design_doc
d['views']['all']['map'].should include('WithTemplate')
end
it "should find all" do
rs = WithTemplate.all :raw => true
rs.should == 'x'
rs = WithTemplate.all
rs.length.should == 4
end
end