Merge branch 'default_fix' of https://github.com/gsterndale/couchrest_model into default_fix

This commit is contained in:
Sam Lown 2011-02-02 20:11:27 +01:00
commit d53c98252e
2 changed files with 10 additions and 2 deletions

View file

@ -58,8 +58,8 @@ module CouchRest::Model
if default.class == Proc
default.call
else
# Marshal.load(Marshal.dump(default)) # Removed as there are no failing tests and caused mutex errors
default
# TODO identify cause of mutex errors
Marshal.load(Marshal.dump(default))
end
end

View file

@ -184,6 +184,14 @@ describe "Model Base" do
obj = WithDefaultValues.new(:preset => 'test')
obj.preset = 'test'
end
it "should keep default values for new instances" do
obj = WithDefaultValues.new
obj.preset[:alpha] = 123
obj.preset.should == {:right => 10, :top_align => false, :alpha => 123}
another = WithDefaultValues.new
another.preset.should == {:right => 10, :top_align => false}
end
it "should work with a default empty array" do
obj = WithDefaultValues.new(:tags => ['spec'])