Merge pull request #4911 from JannikStreek/feature/4904-poll_fed_issue
Fix: federation issue with polls
This commit is contained in:
commit
89a01525a9
3 changed files with 27 additions and 2 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue