diff --git a/spec/requests/api/v1/polls_spec.rb b/spec/requests/api/v1/polls_spec.rb index fd38297931..c93231e1ee 100644 --- a/spec/requests/api/v1/polls_spec.rb +++ b/spec/requests/api/v1/polls_spec.rb @@ -36,6 +36,31 @@ RSpec.describe 'Polls' do end end + context 'when poll is remote and needs refresh' do + let(:poll) { Fabricate(:poll, last_fetched_at: nil, account: remote_account, status: status) } + let(:remote_account) { Fabricate :account, domain: 'host.example' } + let(:service) { instance_double(ActivityPub::FetchRemotePollService, call: nil) } + let(:status) { Fabricate(:status, visibility: 'public', account: remote_account) } + + before { allow(ActivityPub::FetchRemotePollService).to receive(:new).and_return(service) } + + it 'returns poll data and calls fetch remote service' do + subject + + expect(response) + .to have_http_status(200) + expect(response.content_type) + .to start_with('application/json') + expect(response.parsed_body).to match( + a_hash_including( + id: poll.id.to_s + ) + ) + expect(service) + .to have_received(:call).with(poll, user.account) + end + end + context 'when parent status is private' do let(:visibility) { 'private' }