bugfix: allow CastedArrays to be assigned
(And be a bit more general about it)
This commit is contained in:
parent
c32992c21b
commit
c2fde42fa6
|
@ -33,7 +33,7 @@ module CouchRest::Model
|
||||||
data.keys.sort.each do |k|
|
data.keys.sort.each do |k|
|
||||||
value << data[k]
|
value << data[k]
|
||||||
end
|
end
|
||||||
elsif value.class != Array
|
elsif !value.is_a?(Array)
|
||||||
raise "Expecting an array or keyed hash for property #{parent.class.name}##{self.name}"
|
raise "Expecting an array or keyed hash for property #{parent.class.name}##{self.name}"
|
||||||
end
|
end
|
||||||
arr = value.collect { |data| cast_value(parent, data) }
|
arr = value.collect { |data| cast_value(parent, data) }
|
||||||
|
|
|
@ -358,6 +358,14 @@ describe CouchRest::Model::CastedModel do
|
||||||
@cat.toys << @toy2
|
@cat.toys << @toy2
|
||||||
end
|
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
|
it "should reference the top document for" do
|
||||||
@course.base_doc.should === @course
|
@course.base_doc.should === @course
|
||||||
@professor.casted_by.should === @course
|
@professor.casted_by.should === @course
|
||||||
|
|
Loading…
Reference in a new issue