fixed class proxy design doc wreidness

This commit is contained in:
Daniel Kirsch 2009-07-21 23:23:12 +02:00
parent 3ee810010d
commit 4d4972f0de
4 changed files with 10 additions and 5 deletions

View file

@ -104,7 +104,7 @@ module CouchRest
end
def refresh_design_doc
@klass.refresh_design_doc
@klass.refresh_design_doc_on(@database)
end
def save_design_doc

View file

@ -48,6 +48,11 @@ module CouchRest
save_design_doc
end
def refresh_design_doc_on(db)
reset_design_doc
save_design_doc_on(db)
end
# Save the design doc onto the default database, and update the
# design_doc attribute
def save_design_doc

View file

@ -95,11 +95,11 @@ module CouchRest
# Dispatches to any named view.
def view(name, query={}, &block)
unless design_doc_fresh
refresh_design_doc
db = query.delete(:database) || database
unless design_doc_fresh
refresh_design_doc_on(db)
end
query[:raw] = true if query[:reduce]
db = query.delete(:database) || database
raw = query.delete(:raw)
fetch_view_with_docs(db, name, query, raw, &block)
end

View file

@ -200,7 +200,7 @@ describe "ExtendedDocument views" do
before(:all) do
reset_test_db!
# setup the class default doc to save the design doc
Unattached.use_database DB
Unattached.use_database nil # just to be sure it is really unattached
@us = Unattached.on(DB)
%w{aaa bbb ddd eee}.each do |title|
u = @us.new(:title => title)