Skip to content
Extraits de code Groupes Projets
Valider f0df6dee rédigé par danielgrippi's avatar danielgrippi Validation de Raphael Sofaer
Parcourir les fichiers

added job and spec for BatchLocalReceive. wip

parent 149b1832
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
module Job
class ReceiveLocalBatch < Base
require File.join(Rails.root, 'lib/postzord/receiver')
@queue = :receive
def self.perform_delegate(author_id, post_id, recipient_user_ids)
end
def self.create_visibilities(post, recipient_user_ids)
aspects = Aspect.where(:user_id => recipient_user_ids).joins(:contacts).where(:contacts => {:person_id => post.author_id}).select('aspects.id')
aspects.each do |aspect|
PostVisibility.create(:aspect_id => aspect.id, :post_id => post.id)
post.socket_to_user(aspect.user_id, :aspect_ids => [aspect.id]) if post.respond_to? :socket_to_user
end
end
end
end
require 'spec_helper'
describe Job::ReceiveLocalBatch do
#takes author id, post id and array of receiving user ids
#for each recipient, it gets the aspects that the author is in
#Gets all the aspect ids, and inserts into post_visibilities for each aspect
#Then it sockets to those users
#And notifies mentioned people
before do
@post = alice.build_post(:status_message, :text => 'Hey Bob')
@post.save!
end
describe '.perform_delegate' do
it 'calls .create_visibilities' do
end
it 'sockets to users' do
end
it 'notifies mentioned users' do
end
end
describe '.create_visibilities' do
it 'creates a visibility for each user' do
PostVisibility.exists?(:aspect_id => bob.aspects.first, :post_id => @post.id).should be_false
Job::ReceiveLocalBatch.create_visibilities(@post, [bob.id])
PostVisibility.exists?(:aspect_id => bob.aspects.first, :post_id => @post.id).should be_true
end
end
describe '.socket_to_users' do
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