闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.6 KiB

  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. before do
  30. stub_request(:post, 'http://example.com/inbox').to_return(status: 200)
  31. follower.follow!(reblogger)
  32. Fabricate(:status, account: reblogger, reblog: status)
  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. # one for Delete original post, and one for Undo reblog (normal delivery)
  40. expect(a_request(:post, 'http://example.com/inbox')).to have_been_made.twice
  41. end
  42. end
  43. end
  44. end