Skip to content
Extraits de code Groupes Projets
Valider c20cd538 rédigé par Maxwell Salzberg's avatar Maxwell Salzberg
Parcourir les fichiers

create a new notifciation if previous was read, only concatinate when it is the same unread message

parent c41acbab
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -41,7 +41,8 @@ private
def self.concatenate_or_create(recipient, target, actor, notification_type)
if n = notification_type.where(:target_id => target.id,
:target_type => target.class.base_class,
:recipient_id => recipient.id).first
:recipient_id => recipient.id,
:unread => true).first
unless n.actors.include?(actor)
n.actors << actor
end
......
......@@ -12,11 +12,12 @@ describe Notification do
@user2 = eve
@aspect = @user.aspects.create(:name => "dudes")
@opts = {:target_id => @sm.id,
:target_type => @sm.class.name,
:target_type => @sm.class.base_class.to_s,
:type => 'Notifications::CommentOnPost',
:actors => [@person],
:recipient_id => @user.id}
@note = Notification.new(@opts)
@note.type = 'Notifications::CommentOnPost'
@note.actors =[ @person]
end
......@@ -39,6 +40,15 @@ describe Notification do
end
end
describe '.concatenate_or_create' do
it 'creates a new notificiation if the notification does not exist, or if it is unread' do
@note.unread = false
@note.save
Notification.count.should == 1
Notification.concatenate_or_create(@note.recipient, @note.target, @note.actors.first, Notifications::CommentOnPost)
Notification.count.should == 2
end
end
describe '.notify' do
it 'does not call Notification.create if the object does not have a notification_type' do
Notification.should_not_receive(:make_notificatin)
......@@ -104,15 +114,6 @@ describe Notification do
Notification.where(:recipient_id => @user3.id, :target_type => @sm.class.base_class, :target_id => @sm.id).first.actors.count.should == 2
end
it 'marks the notification as unread' do
note = Notification.where(:recipient_id => @user3.id,:target_type => @sm.class.base_class, :target_id => @sm.id).first
note.unread = false
note.save
lambda {
Postzord::Receiver.new(@user3, :person => @user2.person, :object => @user2.comment("hey", :on => @sm)).receive_object
note.reload
}.should change(note, :unread).from(false).to(true)
end
end
end
end
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter