提交 9a5f3283 编写于 作者: D Dmitriy Zaporozhets

notes should depends on user when destroy

上级 eb96336d
......@@ -16,6 +16,10 @@ class User < ActiveRecord::Base
:foreign_key => :author_id,
:dependent => :destroy
has_many :notes,
:foreign_key => :author_id,
:dependent => :destroy
has_many :assigned_issues,
:class_name => "Issue",
:foreign_key => :assignee_id,
......
......@@ -18,6 +18,21 @@ describe User do
user = User.new(:email => "test@mail.com")
user.identifier.should == "test_mail.com"
end
describe "dependent" do
before do
@user = Factory :user
@note = Factory :note,
:author => @user,
:project => Factory(:project)
end
it "should destroy all notes with user" do
Note.find_by_id(@note.id).should_not be_nil
@user.destroy
Note.find_by_id(@note.id).should be_nil
end
end
end
# == Schema Information
#
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册