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.

70 lines
1.9 KiB

  1. require 'rails_helper'
  2. RSpec.describe ActivityPub::Activity::Announce do
  3. let(:sender) { Fabricate(:account, followers_url: 'http://example.com/followers') }
  4. let(:recipient) { Fabricate(:account) }
  5. let(:status) { Fabricate(:status, account: recipient) }
  6. let(:json) do
  7. {
  8. '@context': 'https://www.w3.org/ns/activitystreams',
  9. id: 'foo',
  10. type: 'Announce',
  11. actor: ActivityPub::TagManager.instance.uri_for(sender),
  12. object: object_json,
  13. }.with_indifferent_access
  14. end
  15. subject { described_class.new(json, sender) }
  16. before do
  17. sender.update(uri: ActivityPub::TagManager.instance.uri_for(sender))
  18. end
  19. describe '#perform' do
  20. before do
  21. subject.perform
  22. end
  23. context 'a known status' do
  24. let(:object_json) do
  25. ActivityPub::TagManager.instance.uri_for(status)
  26. end
  27. it 'creates a reblog by sender of status' do
  28. expect(sender.reblogged?(status)).to be true
  29. end
  30. end
  31. context 'self-boost of a previously unknown status with missing attributedTo' do
  32. let(:object_json) do
  33. {
  34. id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
  35. type: 'Note',
  36. content: 'Lorem ipsum',
  37. to: 'http://example.com/followers',
  38. }
  39. end
  40. it 'creates a reblog by sender of status' do
  41. expect(sender.reblogged?(sender.statuses.first)).to be true
  42. end
  43. end
  44. context 'self-boost of a previously unknown status with correct attributedTo' do
  45. let(:object_json) do
  46. {
  47. id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
  48. type: 'Note',
  49. content: 'Lorem ipsum',
  50. attributedTo: ActivityPub::TagManager.instance.uri_for(sender),
  51. to: 'http://example.com/followers',
  52. }
  53. end
  54. it 'creates a reblog by sender of status' do
  55. expect(sender.reblogged?(sender.statuses.first)).to be true
  56. end
  57. end
  58. end
  59. end