From ad07521e078402a0f82343403c7cc8f38bf59407 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 16 Aug 2010 16:22:46 -0700 Subject: [PATCH] Made a few more tests pass --- app/models/person.rb | 10 ++-------- app/models/user.rb | 1 - spec/helpers/requests_helper_spec.rb | 8 -------- spec/models/comments_spec.rb | 25 ++++++++++++++++++++----- spec/spec_helper.rb | 1 + 5 files changed, 23 insertions(+), 22 deletions(-) diff --git a/app/models/person.rb b/app/models/person.rb index d7fa74418..57eb8d6ed 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -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 ) diff --git a/app/models/user.rb b/app/models/user.rb index 16a58862e..8394c3fdf 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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? diff --git a/spec/helpers/requests_helper_spec.rb b/spec/helpers/requests_helper_spec.rb index 8419bd566..325597bf3 100644 --- a/spec/helpers/requests_helper_spec.rb +++ b/spec/helpers/requests_helper_spec.rb @@ -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 diff --git a/spec/models/comments_spec.rb b/spec/models/comments_spec.rb index 3be395644..6d6aa7c3c 100644 --- a/spec/models/comments_spec.rb +++ b/spec/models/comments_spec.rb @@ -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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index fb730c6db..d0b2759cb 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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