added pending specs. traced the whole comment thing -- it works, but i couldn't figure out how to make these pending specs pass (re: should_receive)
This commit is contained in:
parent
05174436c0
commit
c35be73978
5 changed files with 75 additions and 9 deletions
|
|
@ -309,6 +309,7 @@ class User
|
|||
#been associated and saved by post owner
|
||||
# (we'll push to all of their aspects for now, the comment won't
|
||||
# show up via js where corresponding posts are not present)
|
||||
|
||||
people_in_aspects(aspects, :type => 'local').each do |person|
|
||||
comment.socket_to_uid(person.owner_id, :aspect_ids => 'all')
|
||||
end
|
||||
|
|
|
|||
|
|
@ -63,12 +63,11 @@ module Diaspora
|
|||
people = Person.all(:id.in => person_ids)
|
||||
|
||||
if opts[:type] == 'remote'
|
||||
people.delete_if{ |p| !p.owner_id.blank? }
|
||||
people.delete_if{ |p| !p.owner.blank? }
|
||||
elsif opts[:type] == 'local'
|
||||
people.delete_if{ |p| p.owner_id.blank? }
|
||||
else
|
||||
people
|
||||
people.delete_if{ |p| p.owner.blank? }
|
||||
end
|
||||
people
|
||||
end
|
||||
|
||||
def aspect_by_id( id )
|
||||
|
|
|
|||
|
|
@ -121,8 +121,8 @@ module Diaspora
|
|||
|
||||
#dispatch comment DOWNSTREAM, received it via UPSTREAM
|
||||
unless owns?(comment)
|
||||
dispatch_comment comment
|
||||
comment.save
|
||||
dispatch_comment comment
|
||||
end
|
||||
|
||||
comment.socket_to_uid(self.id, :aspect_ids => comment.post.aspect_ids)
|
||||
|
|
|
|||
58
spec/models/user/commenting_spec.rb
Normal file
58
spec/models/user/commenting_spec.rb
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
# 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'
|
||||
|
||||
describe User do
|
||||
|
||||
let!(:user1){make_user}
|
||||
let!(:user2){make_user}
|
||||
let!(:aspect1){user1.aspects.create(:name => 'heroes')}
|
||||
let!(:aspect2){user2.aspects.create(:name => 'others')}
|
||||
|
||||
before do
|
||||
connect_users(user1, aspect1, user2, aspect2)
|
||||
@post = user1.build_post(:status_message, :message => "hey", :to => aspect1.id)
|
||||
@post.save
|
||||
user1.dispatch_post(@post, :to => "all")
|
||||
end
|
||||
|
||||
describe '#dispatch_comment' do
|
||||
|
||||
context 'post owners contact comments on post' do
|
||||
it 'should not call receive on local users' do
|
||||
pending 'need to call should_receive without it being destructive'
|
||||
|
||||
user1.should_receive(:receive_comment)
|
||||
user2.should_not_receive(:receive_comment)
|
||||
user1.should_receive(:dispatch_comment)
|
||||
|
||||
user1.reload
|
||||
user2.reload
|
||||
|
||||
comment = user2.build_comment "why so formal?", :on => @post
|
||||
comment.save!
|
||||
user2.dispatch_comment comment
|
||||
end
|
||||
end
|
||||
|
||||
context 'post owner comments on own post' do
|
||||
it 'should only dispatch once' do
|
||||
pending 'need to call should_receive without it being destructive'
|
||||
|
||||
user1.should_receive(:dispatch_comment).once
|
||||
user2.should_not_receive(:receive_comment)
|
||||
user2.should_not_receive(:dispatch_comment)
|
||||
|
||||
user1.reload
|
||||
user2.reload
|
||||
|
||||
comment = user1.build_comment "why so serious?", :on => @post
|
||||
comment.save
|
||||
user1.dispatch_comment comment
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
@ -130,14 +130,14 @@ describe User do
|
|||
end
|
||||
|
||||
describe '#people_in_aspects' do
|
||||
it 'should return people objects for a users contact in each aspect' do
|
||||
it 'returns people objects for a users contact in each aspect' do
|
||||
people = user.people_in_aspects([first_aspect])
|
||||
people.should == [user4.person]
|
||||
people = user.people_in_aspects([second_aspect])
|
||||
people.should == [user2.person]
|
||||
end
|
||||
|
||||
it 'should return local/remote people objects for a users contact in each aspect' do
|
||||
it 'returns local/remote people objects for a users contact in each aspect' do
|
||||
local_user1 = make_user
|
||||
local_user2 = make_user
|
||||
remote_user = make_user
|
||||
|
|
@ -159,6 +159,14 @@ describe User do
|
|||
user.people_in_aspects([first_aspect], :type => 'remote').count.should == 1
|
||||
user.people_in_aspects([first_aspect], :type => 'local').count.should == 3
|
||||
end
|
||||
|
||||
it 'does not return people not connected to user on same pod' do
|
||||
local_user1 = make_user
|
||||
local_user2 = make_user
|
||||
local_user3 = make_user
|
||||
|
||||
user.people_in_aspects([first_aspect]).count.should == 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue