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.

64 lines
1.7 KiB

  1. require 'rails_helper'
  2. RSpec.describe ActivityPub::Activity::Accept do
  3. let(:sender) { Fabricate(:account) }
  4. let(:recipient) { Fabricate(:account) }
  5. let(:json) do
  6. {
  7. '@context': 'https://www.w3.org/ns/activitystreams',
  8. id: 'foo',
  9. type: 'Accept',
  10. actor: ActivityPub::TagManager.instance.uri_for(sender),
  11. object: {
  12. id: 'bar',
  13. type: 'Follow',
  14. actor: ActivityPub::TagManager.instance.uri_for(recipient),
  15. object: ActivityPub::TagManager.instance.uri_for(sender),
  16. },
  17. }.with_indifferent_access
  18. end
  19. describe '#perform' do
  20. subject { described_class.new(json, sender) }
  21. before do
  22. Fabricate(:follow_request, account: recipient, target_account: sender)
  23. subject.perform
  24. end
  25. it 'creates a follow relationship' do
  26. expect(recipient.following?(sender)).to be true
  27. end
  28. it 'removes the follow request' do
  29. expect(recipient.requested?(sender)).to be false
  30. end
  31. end
  32. context 'given a relay' do
  33. let!(:relay) { Fabricate(:relay, state: :pending, follow_activity_id: 'https://abc-123/456') }
  34. let(:json) do
  35. {
  36. '@context': 'https://www.w3.org/ns/activitystreams',
  37. id: 'foo',
  38. type: 'Accept',
  39. actor: ActivityPub::TagManager.instance.uri_for(sender),
  40. object: {
  41. id: 'https://abc-123/456',
  42. type: 'Follow',
  43. actor: ActivityPub::TagManager.instance.uri_for(recipient),
  44. object: ActivityPub::TagManager.instance.uri_for(sender),
  45. },
  46. }.with_indifferent_access
  47. end
  48. subject { described_class.new(json, sender) }
  49. it 'marks the relay as accepted' do
  50. subject.perform
  51. expect(relay.reload.accepted?).to be true
  52. end
  53. end
  54. end