added couchrest-type back in to model
This commit is contained in:
parent
555764bbe8
commit
8533520ef9
|
@ -116,9 +116,6 @@ module CouchRest
|
|||
unless design_doc_fresh
|
||||
refresh_design_doc
|
||||
end
|
||||
# view_name = "#{design_doc_slug}/all"
|
||||
# raw = opts.delete(:raw)
|
||||
# fetch_view_with_docs(view_name, opts, raw)
|
||||
view :all, opts, &block
|
||||
end
|
||||
|
||||
|
@ -270,8 +267,10 @@ module CouchRest
|
|||
opts = keys.pop if keys.last.is_a?(Hash)
|
||||
opts ||= {}
|
||||
ducktype = opts.delete(:ducktype)
|
||||
# if ducktype
|
||||
# end
|
||||
unless ducktype || opts[:map]
|
||||
opts[:guards] ||= []
|
||||
opts[:guards].push "(doc['couchrest-type'] == '#{self.to_s}')"
|
||||
end
|
||||
keys.push opts
|
||||
self.design_doc.view_by(*keys)
|
||||
self.design_doc_fresh = false
|
||||
|
|
|
@ -412,6 +412,12 @@ describe CouchRest::Model do
|
|||
view['rows'].length.should == 4
|
||||
end
|
||||
|
||||
it "should not include non-Articles" do
|
||||
Article.database.save({"date" => 1})
|
||||
view = Article.by_date :raw => true
|
||||
view['rows'].length.should == 4
|
||||
end
|
||||
|
||||
it "should return the matching objects (with default argument :descending => true)" do
|
||||
articles = Article.by_date
|
||||
articles.collect{|a|a.title}.should == @titles.reverse
|
||||
|
|
Loading…
Reference in a new issue