This commit is contained in:
zhitomirskiyi 2011-01-30 10:00:03 -08:00
parent 17dde3a7b9
commit a4988a28b4
3 changed files with 7 additions and 2 deletions

View file

@ -186,6 +186,6 @@ class Person < ActiveRecord::Base
Post.where(:person_id => id).delete_all
Comment.where(:person_id => id).delete_all
Contact.where(:person_id => id).delete_all
Notification.where(:actors => self).delete_all
Notification.joins(:notification_actors).where(:notification_actors => {:person_id => self.id}).all.each{ |n| n.destroy}
end
end

View file

@ -91,7 +91,7 @@ end
Factory.define(:notification) do |n|
n.association :recipient, :factory => :user
n.association :actor, :factory => :person
n.association :actors, :factory => :person
n.association :target, :factory => :comment
n.after_build do |note|
note.action = note.target.notification_type(note.recipient, note.actor)

View file

@ -33,6 +33,11 @@ describe Notification do
@note.associations[:people].type.should == :many
end
it 'destoys the associated notification_actor' do
@note.save
lambda{@note.destroy}.should change(NotificationActors, :count).by(-1)
end
describe '.for' do
it 'returns all of a users notifications' do
user2 = Factory.create(:user)