fixed a bug with the RestClient optimization, added more callbacks on the ExtendedDocument and added support for casted arrays of objects.
This commit is contained in:
parent
b79bb9a912
commit
3a57ed1414
9 changed files with 277 additions and 56 deletions
|
@ -10,6 +10,7 @@ class DummyModel < CouchRest::ExtendedDocument
|
|||
use_database TEST_SERVER.default_database
|
||||
raise "Default DB not set" if TEST_SERVER.default_database.nil?
|
||||
property :casted_attribute, :cast_as => 'WithCastedModelMixin'
|
||||
property :keywords, :cast_as => ["String"]
|
||||
end
|
||||
|
||||
describe CouchRest::CastedModel do
|
||||
|
@ -55,6 +56,18 @@ describe CouchRest::CastedModel do
|
|||
end
|
||||
end
|
||||
|
||||
describe "casted as an array of a different type" do
|
||||
before(:each) do
|
||||
@obj = DummyModel.new(:keywords => ['couch', 'sofa', 'relax', 'canapé'])
|
||||
end
|
||||
|
||||
it "should cast the array propery" do
|
||||
@obj.keywords.should be_an_instance_of(Array)
|
||||
@obj.keywords.first.should == 'couch'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "saved document with casted models" do
|
||||
before(:each) do
|
||||
@obj = DummyModel.new(:casted_attribute => {:name => 'whatever'})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue