Refactored message_queue getting, fixed retraction spec
This commit is contained in:
parent
5b14c4822c
commit
0f596af5c4
12 changed files with 31 additions and 21 deletions
|
|
@ -61,6 +61,7 @@ class Person
|
|||
if owns?(post)
|
||||
post.notify_people
|
||||
end
|
||||
post
|
||||
end
|
||||
|
||||
######## Commenting ########
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ protected
|
|||
end
|
||||
|
||||
def propagate_retraction
|
||||
puts 'propagating retraction'
|
||||
Retraction.for(self).notify_people
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,9 @@ class Retraction
|
|||
retraction.post_id= object.id
|
||||
retraction.person_id = person_id_from(object)
|
||||
retraction.type = object.class.to_s
|
||||
puts retraction.inspect
|
||||
retraction
|
||||
|
||||
end
|
||||
|
||||
xml_accessor :post_id
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ module Diaspora
|
|||
@@queue = MessageHandler.new
|
||||
|
||||
def notify_people
|
||||
if self.person_id == User.owner.person.id
|
||||
unless self.person.owner.nil?
|
||||
push_to(people_with_permissions)
|
||||
end
|
||||
end
|
||||
|
|
@ -17,6 +17,7 @@ module Diaspora
|
|||
end
|
||||
|
||||
def push_to(recipients)
|
||||
puts "recipients are #{recipients.inspect}"
|
||||
unless recipients.empty?
|
||||
recipients.map!{|x| x = x.url + "receive/"}
|
||||
xml = Post.build_xml_for(self)
|
||||
|
|
|
|||
|
|
@ -4,10 +4,11 @@ describe 'SocketsController' do
|
|||
render_views
|
||||
before do
|
||||
@user = Factory.create(:user)
|
||||
@user.person.save
|
||||
SocketsController.unstub!(:new)
|
||||
#EventMachine::WebSocket.stub!(:start)
|
||||
@controller = SocketsController.new
|
||||
@controller.request = mock_model(Request, :env =>
|
||||
{'warden' => mock_model(Warden, :authenticate? => @user, :authenticate! => @user, :authenticate => @user)})
|
||||
stub_sockets_controller
|
||||
end
|
||||
|
||||
|
|
@ -22,7 +23,7 @@ describe 'SocketsController' do
|
|||
end
|
||||
describe 'actionhash' do
|
||||
before do
|
||||
@message = Factory.create(:status_message, :person => @user)
|
||||
@message = @user.post :status_message, :message => "post through user for victory"
|
||||
end
|
||||
|
||||
it 'should actionhash posts' do
|
||||
|
|
|
|||
|
|
@ -38,10 +38,8 @@ describe Diaspora do
|
|||
end
|
||||
|
||||
it "should send an owners post to their people" do
|
||||
q = Post.send(:class_variable_get, :@@queue)
|
||||
q.should_receive :process
|
||||
message_queue.should_receive :process
|
||||
@user.post :status_message, :message => "hi"
|
||||
@post.save
|
||||
end
|
||||
|
||||
it "should check that it does not send a person's post to an owners people" do
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ describe Comment do
|
|||
|
||||
it 'should not send out comments when we have no people' do
|
||||
status = Factory.create(:status_message, :person => @user.person)
|
||||
Comment.send(:class_variable_get, :@@queue).should_not_receive(:add_post_request)
|
||||
message_queue.should_not_receive(:add_post_request)
|
||||
@user.comment "sup dog", :on => status
|
||||
end
|
||||
|
||||
|
|
@ -40,29 +40,28 @@ describe Comment do
|
|||
end
|
||||
|
||||
it "should send a user's comment on a person's post to that person" do
|
||||
Comment.send(:class_variable_get, :@@queue).should_receive(:add_post_request)
|
||||
message_queue.should_receive(:add_post_request)
|
||||
@user.comment "yo", :on => @person_status
|
||||
end
|
||||
|
||||
it 'should send a user comment on his own post to lots of people' do
|
||||
allowed_urls = @user_status.people_with_permissions.map!{|x| x = x.url + "receive/"}
|
||||
puts allowed_urls
|
||||
queue = Comment.send(:class_variable_get, :@@queue)
|
||||
queue.should_receive(:add_post_request).with(allowed_urls, anything)
|
||||
message_queue.should_receive(:add_post_request).with(allowed_urls, anything)
|
||||
@user.comment "yo", :on => @user_status
|
||||
end
|
||||
|
||||
it 'should send a comment a person made on your post to all people' do
|
||||
Comment.send(:class_variable_get, :@@queue).should_receive(:add_post_request)
|
||||
message_queue.should_receive(:add_post_request)
|
||||
@person.comment "balls", :on => @user_status
|
||||
end
|
||||
|
||||
it 'should not send a comment a person made on his own post to anyone' do
|
||||
Comment.send(:class_variable_get, :@@queue).should_not_receive(:add_post_request)
|
||||
message_queue.should_not_receive(:add_post_request)
|
||||
@person.comment "balls", :on => @person_status
|
||||
end
|
||||
it 'should not send a comment a person made on a person post to anyone' do
|
||||
Comment.send(:class_variable_get, :@@queue).should_not_receive(:add_post_request)
|
||||
message_queue.should_not_receive(:add_post_request)
|
||||
@person2.comment "balls", :on => @person_status
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ describe Photo do
|
|||
photo.image.read.nil?.should be false
|
||||
end
|
||||
|
||||
it 'should save a @photo to GridFS' do
|
||||
it 'should save a photo to GridFS' do
|
||||
@photo.image.store! File.open(@fixture_name)
|
||||
@photo.save.should == true
|
||||
binary = @photo.image.read
|
||||
|
|
@ -92,7 +92,7 @@ describe Photo do
|
|||
stub_signature_verification
|
||||
end
|
||||
|
||||
it 'should save a signed @photo to GridFS' do
|
||||
it 'should save a signed photo to GridFS' do
|
||||
photo = Photo.create(:person => @user.person, :album => @album, :image => File.open(@fixture_name))
|
||||
photo.save.should == true
|
||||
photo.verify_creator_signature.should be true
|
||||
|
|
|
|||
|
|
@ -3,7 +3,11 @@ require File.dirname(__FILE__) + '/../spec_helper'
|
|||
describe Retraction do
|
||||
before do
|
||||
@user = Factory.create(:user)
|
||||
@post = Factory.create(:status_message, :person => @user)
|
||||
@user.person.save
|
||||
@post = @user.post(:status_message, :message => "Destroy!")
|
||||
@person = Factory.create(:person)
|
||||
@user.friends << @person
|
||||
@user.save
|
||||
end
|
||||
describe 'serialization' do
|
||||
it 'should have a post id after serialization' do
|
||||
|
|
@ -15,7 +19,7 @@ describe Retraction do
|
|||
describe 'dispatching' do
|
||||
it 'should dispatch a message on delete' do
|
||||
Factory.create(:person)
|
||||
Post.send(:class_variable_get, :@@queue).should_receive(:add_post_request)
|
||||
message_queue.should_receive(:add_post_request)
|
||||
@post.destroy
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -55,8 +55,7 @@ describe User do
|
|||
|
||||
updated_profile = {:profile => {:first_name => 'bob', :last_name => 'billytown', :image_url => "http://clown.com"}}
|
||||
|
||||
queue = Profile.send :class_variable_get, :@@queue
|
||||
queue.should_receive(:process)
|
||||
message_queue.should_receive(:process)
|
||||
|
||||
@user.person.update_profile(updated_profile).should == true
|
||||
@user.profile.image_url.should == "http://clown.com"
|
||||
|
|
|
|||
|
|
@ -71,3 +71,7 @@ end
|
|||
end
|
||||
models
|
||||
end
|
||||
|
||||
def message_queue
|
||||
Post.send(:class_variable_get, :@@queue)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -36,8 +36,8 @@ describe 'user encryption' do
|
|||
@user.key.should_not be nil
|
||||
end
|
||||
describe 'key exchange on friending' do
|
||||
it 'should send over a public key' do
|
||||
Comment.send(:class_variable_get, :@@queue).stub!(:add_post_request)
|
||||
it 'should send over a public key' do
|
||||
message_queue.stub!(:add_post_request)
|
||||
request = @user.send_friend_request_to("http://example.com/")
|
||||
Request.build_xml_for([request]).include?( @user.export_key).should be true
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue