Skip to content

Commit 282e8b3

Browse files
ClearlyClairehiyuki2578
authored andcommitted
Fix account URI in UpdatePollSerializer (mastodon#11194)
* Fix account URI in UpdatePollSerializer Fixes mastodon#11185 * Add specs
1 parent 6b678df commit 282e8b3

3 files changed

Lines changed: 50 additions & 1 deletion

File tree

app/serializers/activitypub/update_poll_serializer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def type
1414
end
1515

1616
def actor
17-
ActivityPub::TagManager.instance.uri_for(object)
17+
ActivityPub::TagManager.instance.uri_for(object.account)
1818
end
1919

2020
def to
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# frozen_string_literal: true
2+
3+
require 'rails_helper'
4+
5+
describe ActivityPub::UpdatePollSerializer do
6+
let(:account) { Fabricate(:account) }
7+
let(:poll) { Fabricate(:poll, account: account) }
8+
let!(:status) { Fabricate(:status, account: account, poll: poll) }
9+
10+
before(:each) do
11+
@serialization = ActiveModelSerializers::SerializableResource.new(status, serializer: ActivityPub::UpdatePollSerializer, adapter: ActivityPub::Adapter)
12+
end
13+
14+
subject { JSON.parse(@serialization.to_json) }
15+
16+
it 'has a Update type' do
17+
expect(subject['type']).to eql('Update')
18+
end
19+
20+
it 'has an object with Question type' do
21+
expect(subject['object']['type']).to eql('Question')
22+
end
23+
24+
it 'has the correct actor URI set' do
25+
expect(subject['actor']).to eql(ActivityPub::TagManager.instance.uri_for(account))
26+
end
27+
end
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
require 'rails_helper'
2+
3+
describe ActivityPub::DistributePollUpdateWorker do
4+
subject { described_class.new }
5+
6+
let(:account) { Fabricate(:account) }
7+
let(:follower) { Fabricate(:account, protocol: :activitypub, inbox_url: 'http://example.com') }
8+
let(:poll) { Fabricate(:poll, account: account) }
9+
let!(:status) { Fabricate(:status, account: account, poll: poll) }
10+
11+
describe '#perform' do
12+
before do
13+
allow(ActivityPub::DeliveryWorker).to receive(:push_bulk)
14+
follower.follow!(account)
15+
end
16+
17+
it 'delivers to followers' do
18+
subject.perform(status.id)
19+
expect(ActivityPub::DeliveryWorker).to have_received(:push_bulk).with(['http://example.com'])
20+
end
21+
end
22+
end

0 commit comments

Comments
 (0)