mirror of
https://github.com/mastodon/mastodon.git
synced 2025-02-06 06:55:04 +00:00
Prep work for coverage addition to ActivityPub::DeliveryWorker
spec (#32944)
Some checks are pending
Check i18n / check-i18n (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
Ruby Linting / lint (push) Waiting to run
Historical data migration test / test (14-alpine) (push) Waiting to run
Historical data migration test / test (15-alpine) (push) Waiting to run
Historical data migration test / test (16-alpine) (push) Waiting to run
Historical data migration test / test (17-alpine) (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / Libvips tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / Libvips tests (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Some checks are pending
Check i18n / check-i18n (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
Ruby Linting / lint (push) Waiting to run
Historical data migration test / test (14-alpine) (push) Waiting to run
Historical data migration test / test (15-alpine) (push) Waiting to run
Historical data migration test / test (16-alpine) (push) Waiting to run
Historical data migration test / test (17-alpine) (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / Libvips tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / Libvips tests (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
This commit is contained in:
parent
30a7986569
commit
295ad6f19a
|
@ -5,26 +5,45 @@ require 'rails_helper'
|
||||||
RSpec.describe ActivityPub::DeliveryWorker do
|
RSpec.describe ActivityPub::DeliveryWorker do
|
||||||
include RoutingHelper
|
include RoutingHelper
|
||||||
|
|
||||||
subject { described_class.new }
|
let(:sender) { Fabricate(:account) }
|
||||||
|
|
||||||
let(:sender) { Fabricate(:account) }
|
|
||||||
let(:payload) { 'test' }
|
let(:payload) { 'test' }
|
||||||
|
let(:url) { 'https://example.com/api' }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(sender).to receive(:remote_followers_hash).with('https://example.com/api').and_return('somehash')
|
allow(sender).to receive(:remote_followers_hash).with(url).and_return('somehash')
|
||||||
allow(Account).to receive(:find).with(sender.id).and_return(sender)
|
allow(Account).to receive(:find).with(sender.id).and_return(sender)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'perform' do
|
describe 'perform' do
|
||||||
it 'performs a request' do
|
context 'with successful request' do
|
||||||
stub_request(:post, 'https://example.com/api').to_return(status: 200)
|
before { stub_request(:post, url).to_return(status: 200) }
|
||||||
subject.perform(payload, sender.id, 'https://example.com/api', { synchronize_followers: true })
|
|
||||||
expect(a_request(:post, 'https://example.com/api').with(headers: { 'Collection-Synchronization' => "collectionId=\"#{account_followers_url(sender)}\", digest=\"somehash\", url=\"#{account_followers_synchronization_url(sender)}\"" })).to have_been_made.once
|
it 'performs a request to synchronize collection' do
|
||||||
|
subject.perform(payload, sender.id, url, { synchronize_followers: true })
|
||||||
|
|
||||||
|
expect(request_to_url)
|
||||||
|
.to have_been_made.once
|
||||||
|
end
|
||||||
|
|
||||||
|
def request_to_url
|
||||||
|
a_request(:post, url)
|
||||||
|
.with(
|
||||||
|
headers: {
|
||||||
|
'Collection-Synchronization' => <<~VALUES.squish,
|
||||||
|
collectionId="#{account_followers_url(sender)}", digest="somehash", url="#{account_followers_synchronization_url(sender)}"
|
||||||
|
VALUES
|
||||||
|
}
|
||||||
|
)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'raises when request fails' do
|
context 'with failing request' do
|
||||||
stub_request(:post, 'https://example.com/api').to_return(status: 500)
|
before { stub_request(:post, url).to_return(status: 500) }
|
||||||
expect { subject.perform(payload, sender.id, 'https://example.com/api') }.to raise_error Mastodon::UnexpectedResponseError
|
|
||||||
|
it 'raises error' do
|
||||||
|
expect { subject.perform(payload, sender.id, url) }
|
||||||
|
.to raise_error Mastodon::UnexpectedResponseError
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user