logo

mastofe

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

delete_spec.rb (1601B)


  1. require 'rails_helper'
  2. RSpec.describe ActivityPub::Activity::Delete do
  3. let(:sender) { Fabricate(:account, domain: 'example.com') }
  4. let(:status) { Fabricate(:status, account: sender, uri: 'foobar') }
  5. let(:json) do
  6. {
  7. '@context': 'https://www.w3.org/ns/activitystreams',
  8. id: 'foo',
  9. type: 'Delete',
  10. actor: ActivityPub::TagManager.instance.uri_for(sender),
  11. object: ActivityPub::TagManager.instance.uri_for(status),
  12. signature: 'foo',
  13. }.with_indifferent_access
  14. end
  15. describe '#perform' do
  16. subject { described_class.new(json, sender) }
  17. before do
  18. subject.perform
  19. end
  20. it 'deletes sender\'s status' do
  21. expect(Status.find_by(id: status.id)).to be_nil
  22. end
  23. end
  24. context 'when the status has been reblogged' do
  25. describe '#perform' do
  26. subject { described_class.new(json, sender) }
  27. let!(:reblogger) { Fabricate(:account) }
  28. let!(:follower) { Fabricate(:account, username: 'follower', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') }
  29. let!(:reblog) { Fabricate(:status, account: reblogger, reblog: status) }
  30. before do
  31. stub_request(:post, 'http://example.com/inbox').to_return(status: 200)
  32. follower.follow!(reblogger)
  33. subject.perform
  34. end
  35. it 'deletes sender\'s status' do
  36. expect(Status.find_by(id: status.id)).to be_nil
  37. end
  38. it 'sends delete activity to followers of rebloggers' do
  39. expect(a_request(:post, 'http://example.com/inbox')).to have_been_made.once
  40. end
  41. end
  42. end
  43. end