From b8bda3bb02b6958e93bdd39845afe378a5bc9984 Mon Sep 17 00:00:00 2001 From: deepj Date: Tue, 10 Nov 2009 03:23:55 +0100 Subject: [PATCH] Initialization of ExtendentDocument model shouldn't failed on a nil value in argument MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tapajós --- lib/couchrest/more/extended_document.rb | 2 +- spec/couchrest/more/extended_doc_spec.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/couchrest/more/extended_document.rb b/lib/couchrest/more/extended_document.rb index cce0d89..73c1b17 100644 --- a/lib/couchrest/more/extended_document.rb +++ b/lib/couchrest/more/extended_document.rb @@ -41,7 +41,7 @@ module CouchRest def initialize(passed_keys={}) apply_defaults # defined in CouchRest::Mixins::Properties - set_attributes(passed_keys) + set_attributes(passed_keys) unless passed_keys.nil? super cast_keys # defined in CouchRest::Mixins::Properties unless self['_id'] && self['_rev'] diff --git a/spec/couchrest/more/extended_doc_spec.rb b/spec/couchrest/more/extended_doc_spec.rb index 1f91dcf..f055576 100644 --- a/spec/couchrest/more/extended_doc_spec.rb +++ b/spec/couchrest/more/extended_doc_spec.rb @@ -129,6 +129,11 @@ describe "ExtendedDocument" do @obj.should be_new_document @obj.should be_new_record end + + it "should not failed on a nil value in argument" do + @obj = Basic.new(nil) + @obj.should == { 'couchrest-type' => 'Basic' } + end end describe "creating a new document" do