Added the method update_attributes_without_saving.
To understand the reason, say you have this: class Post < CouchRest::Model key_accessor :title, :body, :author, comments cast :author, :as => 'Author' cast :comments, :as => ['Comment'] end comment = post.comments.first I'd like to do comment.update_attributes_without_saving hash because otherwise, it would create a new document for comment, which I don't want in my particular use. I just want to update the internal comment in the post.
This commit is contained in:
parent
60c5994e43
commit
9399b27f3f
2 changed files with 20 additions and 5 deletions
|
@ -134,7 +134,7 @@ describe CouchRest::Model do
|
|||
end
|
||||
end
|
||||
|
||||
describe "update attributes" do
|
||||
describe "update attributes without saving" do
|
||||
before(:each) do
|
||||
a = Article.get "big-bad-danger" rescue nil
|
||||
a.destroy if a
|
||||
|
@ -160,13 +160,21 @@ describe CouchRest::Model do
|
|||
@art['title'].should == "big bad danger"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "update attributes" do
|
||||
before(:each) do
|
||||
a = Article.get "big-bad-danger" rescue nil
|
||||
a.destroy if a
|
||||
@art = Article.new(:title => "big bad danger")
|
||||
@art.save
|
||||
end
|
||||
it "should save" do
|
||||
@art['title'].should == "big bad danger"
|
||||
@art.update_attributes('date' => Time.now, :title => "super danger")
|
||||
loaded = Article.get @art.id
|
||||
loaded['title'].should == "super danger"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "a model with template values" do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue