authorize_follow_service_spec.rb 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. require 'rails_helper'
  2. RSpec.describe AuthorizeFollowService, type: :service do
  3. let(:sender) { Fabricate(:account, username: 'alice') }
  4. subject { AuthorizeFollowService.new }
  5. describe 'local' do
  6. let(:bob) { Fabricate(:account, username: 'bob') }
  7. before do
  8. FollowRequest.create(account: bob, target_account: sender)
  9. subject.call(bob, sender)
  10. end
  11. it 'removes follow request' do
  12. expect(bob.requested?(sender)).to be false
  13. end
  14. it 'creates follow relation' do
  15. expect(bob.following?(sender)).to be true
  16. end
  17. end
  18. describe 'remote ActivityPub' do
  19. let(:bob) { Fabricate(:account, username: 'bob', domain: 'example.com', protocol: :activitypub, inbox_url: 'http://example.com/inbox') }
  20. before do
  21. FollowRequest.create(account: bob, target_account: sender)
  22. stub_request(:post, bob.inbox_url).to_return(status: 200)
  23. subject.call(bob, sender)
  24. end
  25. it 'removes follow request' do
  26. expect(bob.requested?(sender)).to be false
  27. end
  28. it 'creates follow relation' do
  29. expect(bob.following?(sender)).to be true
  30. end
  31. it 'sends an accept activity' do
  32. expect(a_request(:post, bob.inbox_url)).to have_been_made.once
  33. end
  34. end
  35. end