Merge commit 'sethladd/master'
This commit is contained in:
commit
cdf998b185
7 changed files with 123 additions and 91 deletions
|
@ -43,16 +43,14 @@ describe "assigning a value to casted attribute after initializing an object" do
|
|||
@car.driver.should be_nil
|
||||
end
|
||||
|
||||
# Note that this isn't casting the attribute, it's just assigning it a value
|
||||
# (see "should not cast attribute")
|
||||
it "should let you assign the value" do
|
||||
@car.driver = @driver
|
||||
@car.driver.name.should == 'Matt'
|
||||
end
|
||||
|
||||
it "should not cast attribute" do
|
||||
it "should cast attribute" do
|
||||
@car.driver = JSON.parse(JSON.generate(@driver))
|
||||
@car.driver.should_not be_instance_of(Driver)
|
||||
@car.driver.should be_instance_of(Driver)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -288,7 +288,8 @@ describe CouchRest::CastedModel do
|
|||
before :each do
|
||||
reset_test_db!
|
||||
@cat = Cat.new(:name => 'Sockington')
|
||||
@cat.favorite_toy = CatToy.new(:name => 'Catnip Ball')
|
||||
@favorite_toy = CatToy.new(:name => 'Catnip Ball')
|
||||
@cat.favorite_toy = @favorite_toy
|
||||
@cat.toys << CatToy.new(:name => 'Fuzzy Stick')
|
||||
end
|
||||
|
||||
|
@ -298,6 +299,7 @@ describe CouchRest::CastedModel do
|
|||
end
|
||||
|
||||
it "should be true after assignment" do
|
||||
@cat.should be_new
|
||||
@cat.favorite_toy.should be_new
|
||||
@cat.toys.first.should be_new
|
||||
end
|
||||
|
@ -340,6 +342,7 @@ describe CouchRest::CastedModel do
|
|||
|
||||
it "should reference the top document for" do
|
||||
@course.base_doc.should === @course
|
||||
@professor.casted_by.should === @course
|
||||
@professor.base_doc.should === @course
|
||||
@cat.base_doc.should === @course
|
||||
@toy1.base_doc.should === @course
|
||||
|
@ -347,6 +350,7 @@ describe CouchRest::CastedModel do
|
|||
end
|
||||
|
||||
it "should call setter on top document" do
|
||||
@toy1.base_doc.should_not be_nil
|
||||
@toy1.base_doc.title = 'Tom Foolery'
|
||||
@course.title.should == 'Tom Foolery'
|
||||
end
|
||||
|
|
|
@ -118,7 +118,22 @@ describe "ExtendedDocument" do
|
|||
@art.update_attributes_without_saving('date' => Time.now, :title => "super danger")
|
||||
@art['title'].should == "super danger"
|
||||
end
|
||||
|
||||
it "should silently ignore _id" do
|
||||
@art.update_attributes_without_saving('_id' => 'foobar')
|
||||
@art['_id'].should_not == 'foobar'
|
||||
end
|
||||
it "should silently ignore _rev" do
|
||||
@art.update_attributes_without_saving('_rev' => 'foobar')
|
||||
@art['_rev'].should_not == 'foobar'
|
||||
end
|
||||
it "should silently ignore created_at" do
|
||||
@art.update_attributes_without_saving('created_at' => 'foobar')
|
||||
@art['created_at'].should_not == 'foobar'
|
||||
end
|
||||
it "should silently ignore updated_at" do
|
||||
@art.update_attributes_without_saving('updated_at' => 'foobar')
|
||||
@art['updated_at'].should_not == 'foobar'
|
||||
end
|
||||
it "should also work using attributes= alias" do
|
||||
@art.respond_to?(:attributes=).should be_true
|
||||
@art.attributes = {'date' => Time.now, :title => "something else"}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue