Enabled apply_defaults for CastedModel
This commit is contained in:
parent
96f8d1aa96
commit
0647307acd
2 changed files with 6 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue