Merge branch 'master' of github.com:couchrest/couchrest_model

This commit is contained in:
Sam Lown 2010-09-05 19:18:37 +02:00
commit 31770ba571
2 changed files with 60 additions and 52 deletions

View file

@ -33,7 +33,7 @@ module CouchRest::Model
data.keys.sort.each do |k|
value << data[k]
end
elsif value.class != Array
elsif !value.is_a?(Array)
raise "Expecting an array or keyed hash for property #{parent.class.name}##{self.name}"
end
arr = value.collect { |data| cast_value(parent, data) }

View file

@ -364,6 +364,14 @@ describe CouchRest::Model::CastedModel do
@cat.toys << @toy2
end
it 'should let you copy over casted arrays' do
question = Question.new
@course.questions << question
new_course = Course.new
new_course.questions = @course.questions
new_course.questions.should include(question)
end
it "should reference the top document for" do
@course.base_doc.should === @course
@professor.casted_by.should === @course