Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add a Document#update!(params) method.

This method internally updates the object's attributes,
and saves the object, returning its id.

This completes the Update section.
  • Loading branch information...
commit 3c67a0fb898ce864698005fff26ea7453e13cc8e 1 parent f3563ab
@elliotcm authored
View
4 lib/document/persistence.rb
@@ -44,6 +44,10 @@ def update(params)
return self
end
+ def update!(params)
+ self.update(params).save
+ end
+
def id
@_id
end
View
2  spec/document/persistence_spec.rb
@@ -52,6 +52,7 @@ class TestClass
describe "#update!(params)" do
before(:each) do
@test_object = TestClass.new(:name => 'Test object')
+ @test_object.stub!(:save => (@result = mock(:result)))
end
def update_object
@@ -69,7 +70,6 @@ def update_object
end
it "returns the result of the save" do
- @test_object.stub!(:save => (@result = mock(:result)))
update_object.should == @result
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.