From 26059f63f21b9aa49caff576d0efe0ca2fb5833d Mon Sep 17 00:00:00 2001 From: Chris Anderson Date: Thu, 2 Oct 2008 23:36:39 -0700 Subject: [PATCH] added the Model.all view --- lib/couchrest/core/model.rb | 4 ++++ spec/couchrest/core/model_spec.rb | 7 +++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/couchrest/core/model.rb b/lib/couchrest/core/model.rb index 1a2b08f..27dce2b 100644 --- a/lib/couchrest/core/model.rb +++ b/lib/couchrest/core/model.rb @@ -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) diff --git a/spec/couchrest/core/model_spec.rb b/spec/couchrest/core/model_spec.rb index b79703b..e9b7a1a 100644 --- a/spec/couchrest/core/model_spec.rb +++ b/spec/couchrest/core/model_spec.rb @@ -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