Newer
Older
# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
require 'spec_helper'
before do
@sm = Factory(:status_message)
@person = Factory(:person)
@user = alice
@user2 = eve
@opts = {:target_id => @sm.id,
:target_type => @sm.class.name,
Raphael
a validé
:action => "comment_on_post",
lambda{@note.destroy}.should change(NotificationActor, :count).by(-1)
user2 = Factory.create(:user)
danielvincent
a validé
4.times do
Notification.create(@opts)
end
Notification.create(@opts.merge(:recipient_id => user2.id))
it 'does not call Notification.create if the object does not have a notification_type' do
Notification.should_not_receive(:make_notificatin)
context 'with a request' do
before do
@request = Request.diaspora_initialize(:from => @user.person, :to => @user2.person, :into => @aspect)
end
it 'calls Notification.create if the object has a notification_type' do
Notification.should_receive(:make_notification).once
Notification.notify(@user, @request, @person)
end
danielvincent
a validé
it 'sockets to the recipient' do
opts = {:target_id => @request.id,
Raphael
a validé
:target_type => "Request",
:action => @request.notification_type(@user, @person),
danielvincent
a validé
danielvincent
a validé
n.should_receive(:socket_to_user).once
Notification.notify(@user, @request, @person)
end
describe '#emails_the_user' do
it 'calls mail' do
opts = {
:action => "new_request",
n.stub!(:recipient).and_return @user
n.email_the_user("mock", @person)
it "updates the notification with a more people if one already exists" do
@user3 = bob
sm = @user3.post(:status_message, :message => "comment!", :to => :all)
Postzord::Receiver.new(@user3, :person => @user2.person, :object => @user2.comment("hey", :on => sm)).receive_object
Postzord::Receiver.new(@user3, :person => @user.person, :object => @user.comment("hey", :on => sm)).receive_object
Notification.where(:recipient_id => @user3.id,:target_id => sm.id).first.actors.count.should == 2
danielvincent
a validé
end