logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

delivery_worker_spec.rb (749B)


  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe ActivityPub::DeliveryWorker do
  4. subject { described_class.new }
  5. let(:sender) { Fabricate(:account) }
  6. let(:payload) { 'test' }
  7. describe 'perform' do
  8. it 'performs a request' do
  9. stub_request(:post, 'https://example.com/api').to_return(status: 200)
  10. subject.perform(payload, sender.id, 'https://example.com/api')
  11. expect(a_request(:post, 'https://example.com/api')).to have_been_made.once
  12. end
  13. it 'raises when request fails' do
  14. stub_request(:post, 'https://example.com/api').to_return(status: 500)
  15. expect { subject.perform(payload, sender.id, 'https://example.com/api') }.to raise_error Mastodon::UnexpectedResponseError
  16. end
  17. end
  18. end