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 end
def refresh_design_doc def refresh_design_doc
@klass.refresh_design_doc @klass.refresh_design_doc_on(@database)
end end
def save_design_doc def save_design_doc

View file

@ -48,6 +48,11 @@ module CouchRest
save_design_doc save_design_doc
end 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 # Save the design doc onto the default database, and update the
# design_doc attribute # design_doc attribute
def save_design_doc def save_design_doc

View file

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

View file

@ -200,7 +200,7 @@ describe "ExtendedDocument views" do
before(:all) do before(:all) do
reset_test_db! reset_test_db!
# setup the class default doc to save the design doc # 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) @us = Unattached.on(DB)
%w{aaa bbb ddd eee}.each do |title| %w{aaa bbb ddd eee}.each do |title|
u = @us.new(:title => title) u = @us.new(:title => title)