Don't make design_doc_slug_cache and design_doc_fresh inheritable, because these settings should be specific to the class

This commit is contained in:
Geoff Buesing 2009-03-25 23:04:32 -05:00 committed by Matt Aimonetti
parent 14acd95444
commit 1ee82b714c
2 changed files with 23 additions and 0 deletions

View file

@ -7,6 +7,7 @@ module CouchRest
end end
module ClassMethods module ClassMethods
attr_accessor :design_doc_slug_cache, :design_doc_fresh
# Define a CouchDB view. The name of the view will be the concatenation # Define a CouchDB view. The name of the view will be the concatenation
# of <tt>by</tt> and the keys joined by <tt>_and_</tt> # of <tt>by</tt> and the keys joined by <tt>_and_</tt>

View file

@ -1,5 +1,6 @@
require File.dirname(__FILE__) + '/../../spec_helper' require File.dirname(__FILE__) + '/../../spec_helper'
require File.join(FIXTURE_PATH, 'more', 'card') require File.join(FIXTURE_PATH, 'more', 'card')
require File.join(FIXTURE_PATH, 'more', 'course')
# add a default value # add a default value
Card.property :bg_color, :default => '#ccc' Card.property :bg_color, :default => '#ccc'
@ -13,6 +14,15 @@ class DesignBusinessCard < BusinessCard
property :bg_color, :default => '#eee' property :bg_color, :default => '#eee'
end end
class OnlineCourse < Course; end
class Animal < CouchRest::ExtendedDocument
use_database TEST_SERVER.default_database
property :name
view_by :name
end
class Dog < Animal; end
describe "Subclassing an ExtendedDocument" do describe "Subclassing an ExtendedDocument" do
@ -56,5 +66,17 @@ describe "Subclassing an ExtendedDocument" do
DesignBusinessCard.new.bg_color.should == '#eee' DesignBusinessCard.new.bg_color.should == '#eee'
end end
it "should have a design doc slug based on the subclass name" do
Course.refresh_design_doc
OnlineCourse.design_doc_slug.should =~ /^OnlineCourse/
end
it "should have a it's own design_doc_fresh" do
Animal.refresh_design_doc
Dog.design_doc_fresh.should_not == true
Dog.refresh_design_doc
Dog.design_doc_fresh.should == true
end
end end