Added ExtendedDocument.create({}) and #create!({}) so you don't have to do Model.new.create

This commit is contained in:
Matt Aimonetti 2009-07-17 00:12:33 -07:00
parent 964526193b
commit 5140899041
3 changed files with 36 additions and 2 deletions

View file

@ -97,6 +97,22 @@ describe "ExtendedDocument" do
end
end
describe "creating a new document" do
it "should instantialize and save a document" do
article = Article.create(:title => 'my test')
article.title.should == 'my test'
article.should_not be_new_document
end
it "should trigger the create callbacks" do
doc = WithCallBacks.create(:name => 'my other test')
doc.run_before_create.should be_true
doc.run_after_create.should be_true
doc.run_before_save.should be_true
doc.run_after_save.should be_true
end
end
describe "update attributes without saving" do
before(:each) do
a = Article.get "big-bad-danger" rescue nil