Made a few more tests pass

This commit is contained in:
Raphael 2010-08-16 16:22:46 -07:00
parent 0417c53a4c
commit ad07521e07
5 changed files with 23 additions and 22 deletions

View file

@ -71,20 +71,14 @@ class Person
raise "must comment on something!" unless options[:on]
c = Comment.new(:person_id => self.id, :text => text, :post => options[:on])
if c.save
begin
dispatch_comment c
rescue Exception => e
puts e.inspect
raise e
end
c.socket_to_uid owner.id if owner_id
true
c
else
Rails.logger.warn "this failed to save: #{c.inspect}"
false
end
false
end
def dispatch_comment( c )

View file

@ -147,7 +147,6 @@ class User
def receive xml
object = Diaspora::Parser.from_xml(xml)
Rails.logger.debug("Receiving object:\n#{object.inspect}")
if object.is_a? Retraction
if object.type == 'Person' && object.signature_valid?

View file

@ -10,19 +10,11 @@ describe RequestsHelper do
@max = Redfinger.finger('mbs348@gmail.com')
end
describe "profile" do
it 'should detect how to subscribe to a diaspora or webfinger profile' do
subscription_mode(@tom).should == :friend
subscription_mode(@evan).should == :none
subscription_mode(@max).should == :none
end
it 'should return the correct tag and url for a given address' do
relationship_flow('tom@tom.joindiaspora.com')[:friend].include?("receive/user").should == true
end
end
end

View file

@ -31,9 +31,16 @@ describe Comment do
describe 'comment propagation' do
before do
@group = @user.group(:name => "Doofuses")
@user2 = Factory.create(:user)
@group2 = @user2.group(:name => "Lame-faces")
request = @user.send_friend_request_to(@user2.receive_url, @group.id)
reversed_request = @user2.accept_friend_request( request.id, @group2.id )
@user.receive reversed_request.to_diaspora_xml
@person = Factory.create(:person)
@user.friends << Factory.create(:person)
@user.save
@person2 = Factory.create(:person)
@person_status = Factory.build(:status_message, :person => @person)
@user_status = Factory.build(:status_message, :person => @user.person)
@ -52,16 +59,24 @@ describe Comment do
it 'should send a comment a person made on your post to all people' do
message_queue.should_receive(:add_post_request)
@person.comment "balls", :on => @user_status
comment = Comment.new(:person_id => @person.id, :text => "balls", :post => @user_status)
@user.receive(comment.to_diaspora_xml)
end
it 'should send a comment a user made on your post to all people' do
message_queue.should_receive(:add_post_request).twice
comment = @user2.comment( "balls", :on => @user_status)
@user.receive(comment.to_diaspora_xml)
end
it 'should not send a comment a person made on his own post to anyone' do
message_queue.should_not_receive(:add_post_request)
@person.comment "balls", :on => @person_status
comment = Comment.new(:person_id => @person.id, :text => "balls", :post => @person_status)
@user.receive(comment.to_diaspora_xml)
end
it 'should not send a comment a person made on a person post to anyone' do
message_queue.should_not_receive(:add_post_request)
@person2.comment "balls", :on => @person_status
comment = Comment.new(:person_id => @person2.id, :text => "balls", :post => @person_status)
@user.receive(comment.to_diaspora_xml)
end
end
end

View file

@ -58,6 +58,7 @@ end
Retraction.any_instance.stubs(:verify_signature).returns(true)
Request.any_instance.stubs(:verify_signature).returns(true)
Comment.any_instance.stubs(:verify_post_creator_signature).returns(true)
Comment.any_instance.stubs(:verify_creator_signature).returns(true)
end
def unstub_mocha_stubs