Fix issue #1.

This commit is contained in:
Tapajós 2009-09-03 00:27:04 -03:00
parent 37c6cb30c2
commit 8db522a116
2 changed files with 21 additions and 0 deletions

View file

@ -193,6 +193,7 @@ module CouchRest
# if the document is not saved properly.
def save!
raise "#{self.inspect} failed to save" unless self.save
true
end
# Deletes the document from the database. Runs the :destroy callbacks.

View file

@ -1,6 +1,7 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.join(FIXTURE_PATH, 'more', 'article')
require File.join(FIXTURE_PATH, 'more', 'course')
require File.join(FIXTURE_PATH, 'more', 'card')
describe "ExtendedDocument" do
@ -339,6 +340,25 @@ describe "ExtendedDocument" do
it "should set the type" do
@sobj['couchrest-type'].should == 'Basic'
end
describe "save!" do
before(:each) do
@sobj = Card.new(:first_name => "Marcos", :last_name => "Tapajós")
end
it "should return true if save the document" do
@sobj.save!.should == true
end
it "should raise error if don't save the document" do
@sobj.first_name = nil
lambda { @sobj.save!.should == true }.should raise_error(RuntimeError)
end
end
end
describe "saving a model with a unique_id configured" do