Enabled apply_defaults for CastedModel

This commit is contained in:
Eric Watson 2009-05-25 11:40:01 -05:00 committed by Matt Aimonetti
parent 96f8d1aa96
commit 0647307acd
2 changed files with 6 additions and 1 deletions

View file

@ -17,7 +17,7 @@ module CouchRest
end
def apply_defaults
return unless self.respond_to?(:new_document?) && new_document?
return if self.respond_to?(:new_document?) && (new_document? == false)
return unless self.class.respond_to?(:properties)
return if self.class.properties.empty?
# TODO: cache the default object

View file

@ -10,6 +10,7 @@ class WithCastedModelMixin < Hash
include CouchRest::CastedModel
property :name
property :no_value
property :hash, :default => {}
end
class DummyModel < CouchRest::ExtendedDocument
@ -68,6 +69,10 @@ describe CouchRest::CastedModel do
it "should return nil for the unknown attribute" do
@casted_obj["unknown"].should be_nil
end
it "should return {} for the hash attribute" do
@casted_obj.hash.should == {}
end
end
describe "casted as an array of a different type" do