no notifications on retractions

This commit is contained in:
maxwell 2010-12-15 13:14:46 -08:00
parent 61b2bbbd7d
commit 9555fae33d
4 changed files with 17 additions and 4 deletions

View file

@ -14,5 +14,10 @@ class Notification
timestamps! timestamps!
attr_accessible :object_id, :kind, :user, :person attr_accessible :object_id, :kind, :user_id, :person_id
def for(user, opts={})
query = opts.merge(:user_id => user)
self.all(opts)
end
end end

View file

@ -64,6 +64,9 @@ module Diaspora
end end
def receive_object(object,person) def receive_object(object,person)
unless object.is_a? Retraction
Notification.create(:object_id => object.id, :kind => object.class.name, :person_id => person.id, :user_id => self.id)
end
if object.is_a?(Request) if object.is_a?(Request)
receive_request object, person receive_request object, person
elsif object.is_a?(Profile) elsif object.is_a?(Profile)

View file

@ -11,7 +11,6 @@ describe Notification do
@person = Factory(:person) @person = Factory(:person)
@user = make_user @user = make_user
@note = Notification.new(:object_id => @sm.id, :kind => @sm.class.name, :person => @person, :user => @user) @note = Notification.new(:object_id => @sm.id, :kind => @sm.class.name, :person => @person, :user => @user)
puts @note.inspect
end end
it 'contains a type' do it 'contains a type' do
@ -25,5 +24,9 @@ describe Notification do
it 'contains a person_id' do it 'contains a person_id' do
@note.person.id == @person.id @note.person.id == @person.id
end end
describe '.for' do
end
end end

View file

@ -60,10 +60,12 @@ describe User do
describe '#receive_object' do describe '#receive_object' do
it 'adds a notification for an object' do it 'adds a notification for an object' do
Notification.should_receive(:new) Notification.should_receive(:create)
user = make_user user = make_user
user.receive_object(Factory(:status_message), Factory(:person)) sm = Factory.create(:status_message)
person = Factory.create(:person)
user.should_receive(:receive_post).and_return(true) user.should_receive(:receive_post).and_return(true)
user.receive_object(sm, person)
end end
end end