fixed the design doc cache issue
This commit is contained in:
parent
c35c35157a
commit
295c0f0511
|
@ -2,7 +2,7 @@
|
|||
|
||||
Gem::Specification.new do |s|
|
||||
s.name = %q{couchrest}
|
||||
s.version = "0.27"
|
||||
s.version = "0.28"
|
||||
|
||||
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
||||
s.authors = ["J. Chris Anderson", "Matt Aimonetti"]
|
||||
|
|
|
@ -28,7 +28,7 @@ require 'couchrest/monkeypatches'
|
|||
|
||||
# = CouchDB, close to the metal
|
||||
module CouchRest
|
||||
VERSION = '0.27' unless self.const_defined?("VERSION")
|
||||
VERSION = '0.28' unless self.const_defined?("VERSION")
|
||||
|
||||
autoload :Server, 'couchrest/core/server'
|
||||
autoload :Database, 'couchrest/core/database'
|
||||
|
|
|
@ -236,16 +236,6 @@ module CouchRest
|
|||
copy_doc(doc, dest)
|
||||
end
|
||||
|
||||
def extended_document_classes
|
||||
@extended_document_classes ||= []
|
||||
end
|
||||
|
||||
# store extended document classes so we can clear
|
||||
# their freshness when we reset the DB
|
||||
def register_extended_document_class(klass)
|
||||
extended_document_classes << klass
|
||||
end
|
||||
|
||||
# Compact the database, removing old document revisions and optimizing space use.
|
||||
def compact!
|
||||
CouchRest.post "#{@uri}/_compact"
|
||||
|
@ -288,7 +278,7 @@ module CouchRest
|
|||
private
|
||||
|
||||
def clear_extended_doc_fresh_cache
|
||||
extended_document_classes.each{|klass| klass.design_doc_fresh = false if klass.respond_to?(:design_doc_fresh=) }
|
||||
::CouchRest::ExtendedDocument.subclasses.each{|klass| klass.design_doc_fresh = false if klass.respond_to?(:design_doc_fresh=) }
|
||||
end
|
||||
|
||||
def uri_for_attachment(doc, name)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
require 'mime/types'
|
||||
require File.join(File.dirname(__FILE__), "property")
|
||||
require File.join(File.dirname(__FILE__), '..', 'mixins', 'extended_document_mixins')
|
||||
require "enumerator"
|
||||
|
||||
module CouchRest
|
||||
|
||||
|
@ -12,6 +13,10 @@ module CouchRest
|
|||
include CouchRest::Mixins::DesignDoc
|
||||
include CouchRest::Mixins::ExtendedAttachments
|
||||
include CouchRest::Mixins::ClassProxy
|
||||
|
||||
def self.subclasses
|
||||
ObjectSpace.enum_for(:each_object, class << self; self; end).to_a.delete_if{|k| k == self}
|
||||
end
|
||||
|
||||
def self.inherited(subklass)
|
||||
subklass.send(:include, CouchRest::Mixins::Properties)
|
||||
|
@ -20,15 +25,6 @@ module CouchRest
|
|||
subklass.properties = self.properties.dup
|
||||
end
|
||||
EOS
|
||||
|
||||
# re opening the use_database method so we can register our class
|
||||
subklass.class_eval <<-EOS, __FILE__, __LINE__
|
||||
def self.use_database(db)
|
||||
super
|
||||
db.register_extended_document_class(self) if db.respond_to?(:register_extended_document_class) && !db.extended_document_classes.include?(self)
|
||||
end
|
||||
EOS
|
||||
|
||||
end
|
||||
|
||||
# Accessors
|
||||
|
|
|
@ -61,7 +61,6 @@ describe "ExtendedDocument views" do
|
|||
describe "another model with a simple view" do
|
||||
before(:all) do
|
||||
reset_test_db!
|
||||
Course.design_doc_fresh = false
|
||||
%w{aaa bbb ddd eee}.each do |title|
|
||||
Course.new(:title => title).save
|
||||
end
|
||||
|
@ -109,13 +108,11 @@ describe "ExtendedDocument views" do
|
|||
duck["dept"].should == true
|
||||
end
|
||||
it "should make the design doc" do
|
||||
Course.design_doc_fresh = false
|
||||
@as = Course.by_dept
|
||||
@doc = Course.design_doc
|
||||
@doc["views"]["by_dept"]["map"].should_not include("couchrest")
|
||||
end
|
||||
it "should not look for class" do
|
||||
Course.design_doc_fresh = false
|
||||
@as = Course.by_dept
|
||||
@as[0]['_id'].should == @id
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue