Add "needs refresh" scenario to api/v1/polls request spec (#33608)

This commit is contained in:
Matt Jankowski 2025-01-16 04:00:04 -05:00 committed by GitHub
parent c20824fa76
commit 72abf05269
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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' }