: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,
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
#