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.

49 lines
1.2 KiB

  1. require 'rails_helper'
  2. RSpec.describe ActivityPub::Activity::Follow 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: 'Follow',
  10. actor: ActivityPub::TagManager.instance.uri_for(sender),
  11. object: ActivityPub::TagManager.instance.uri_for(recipient),
  12. }.with_indifferent_access
  13. end
  14. describe '#perform' do
  15. subject { described_class.new(json, sender) }
  16. context 'unlocked account' do
  17. before do
  18. subject.perform
  19. end
  20. it 'creates a follow from sender to recipient' do
  21. expect(sender.following?(recipient)).to be true
  22. end
  23. it 'does not create a follow request' do
  24. expect(sender.requested?(recipient)).to be false
  25. end
  26. end
  27. context 'locked account' do
  28. before do
  29. recipient.update(locked: true)
  30. subject.perform
  31. end
  32. it 'does not create a follow from sender to recipient' do
  33. expect(sender.following?(recipient)).to be false
  34. end
  35. it 'creates a follow request' do
  36. expect(sender.requested?(recipient)).to be true
  37. end
  38. end
  39. end
  40. end