bugfix: allow CastedArrays to be assigned

(And be a bit more general about it)
This commit is contained in:
Will Leinweber 2010-09-01 16:13:52 -05:00
parent c32992c21b
commit c2fde42fa6
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

@ -358,6 +358,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