diff --git a/app/models/poll.rb b/app/models/poll.rb index d43fcec77..356e5e980 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -10,7 +10,7 @@ class Poll < ActiveRecord::Base xml_attr :poll_answers, :as => [PollAnswer] #forward some requests to status message, because a poll is just attached to a status message and is not sharable itself - delegate :author, :author_id, :public?, :subscribers, to: :status_message + delegate :author, :author_id, :diaspora_handle, :public?, :subscribers, to: :status_message validate :enough_poll_answers diff --git a/lib/postzord/receiver/public.rb b/lib/postzord/receiver/public.rb index ae8cdb869..e60da9083 100644 --- a/lib/postzord/receiver/public.rb +++ b/lib/postzord/receiver/public.rb @@ -10,7 +10,7 @@ class Postzord::Receiver::Public < Postzord::Receiver @salmon = Salmon::Slap.from_xml(xml) @author = Webfinger.new(@salmon.author_id).fetch - FEDERATION_LOGGER.info("Receving public post from person:#{@author.id}") + FEDERATION_LOGGER.info("Receiving public object from person:#{@author.id}") end # @return [Boolean] diff --git a/spec/models/poll_participation_spec.rb b/spec/models/poll_participation_spec.rb index 13a9e0f63..fc4713cb8 100644 --- a/spec/models/poll_participation_spec.rb +++ b/spec/models/poll_participation_spec.rb @@ -78,6 +78,31 @@ describe PollParticipation do end end + describe 'federation' do + before do + #Alice is on pod A and another person is on pod B. Alice posts a poll and participates in the poll. + @poll_participant = FactoryGirl.create(:user) + @poll_participant_aspect = @poll_participant.aspects.create(:name => "bruisers") + connect_users(alice, @alices_aspect, @poll_participant, @poll_participant_aspect) + @poll = Poll.new(:question => "hi") + @poll.poll_answers.build(:answer => "a") + @poll.poll_answers.build(:answer => "b") + @post = alice.post :status_message, :text => "hello", :to => @alices_aspect.id + @post.poll = @poll + @poll_participation_alice = alice.participate_in_poll!(@post, @poll.poll_answers.first) + end + + it 'is saved without errors in a simulated A-B node environment' do + #stubs needed because the poll participation is already saved in the test db. This is just a simulated federation! + PollParticipation.any_instance.stub(:save!).and_return(true) + Person.any_instance.stub(:local?).and_return(false) + expect{ + salmon = Salmon::Slap.create_by_user_and_activity(alice, @poll_participation_alice.to_diaspora_xml).xml_for(@poll_participant) + Postzord::Receiver::Public.new(salmon).save_object + }.to_not raise_error + end + end + describe 'it is relayable' do before do @local_luke, @local_leia, @remote_raphael = set_up_friends