From 4d4972f0de44d0733068182c39650d3d5781134c Mon Sep 17 00:00:00 2001 From: Daniel Kirsch Date: Tue, 21 Jul 2009 23:23:12 +0200 Subject: [PATCH] fixed class proxy design doc wreidness --- lib/couchrest/mixins/class_proxy.rb | 2 +- lib/couchrest/mixins/design_doc.rb | 5 +++++ lib/couchrest/mixins/views.rb | 6 +++--- spec/couchrest/more/extended_doc_view_spec.rb | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/couchrest/mixins/class_proxy.rb b/lib/couchrest/mixins/class_proxy.rb index ab5831c..0101639 100644 --- a/lib/couchrest/mixins/class_proxy.rb +++ b/lib/couchrest/mixins/class_proxy.rb @@ -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 diff --git a/lib/couchrest/mixins/design_doc.rb b/lib/couchrest/mixins/design_doc.rb index 661b6ef..a8714c9 100644 --- a/lib/couchrest/mixins/design_doc.rb +++ b/lib/couchrest/mixins/design_doc.rb @@ -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 diff --git a/lib/couchrest/mixins/views.rb b/lib/couchrest/mixins/views.rb index f520998..de530e3 100644 --- a/lib/couchrest/mixins/views.rb +++ b/lib/couchrest/mixins/views.rb @@ -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 diff --git a/spec/couchrest/more/extended_doc_view_spec.rb b/spec/couchrest/more/extended_doc_view_spec.rb index 8bb3e32..1444f4b 100644 --- a/spec/couchrest/more/extended_doc_view_spec.rb +++ b/spec/couchrest/more/extended_doc_view_spec.rb @@ -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)