1
0

reject_follow_service_spec.rb 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. require 'rails_helper'
  2. RSpec.describe RejectFollowService, type: :service do
  3. let(:sender) { Fabricate(:account, username: 'alice') }
  4. subject { RejectFollowService.new }
  5. describe 'local' do
  6. let(:bob) { Fabricate(:user, email: 'bob@example.com', account: Fabricate(:account, username: 'bob')).account }
  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 'does not create follow relation' do
  15. expect(bob.following?(sender)).to be false
  16. end
  17. end
  18. describe 'remote OStatus' do
  19. let(:bob) { Fabricate(:user, email: 'bob@example.com', account: Fabricate(:account, username: 'bob', domain: 'example.com', salmon_url: 'http://salmon.example.com')).account }
  20. before do
  21. FollowRequest.create(account: bob, target_account: sender)
  22. stub_request(:post, "http://salmon.example.com/").to_return(:status => 200, :body => "", :headers => {})
  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 'does not create follow relation' do
  29. expect(bob.following?(sender)).to be false
  30. end
  31. end
  32. describe 'remote ActivityPub' do
  33. let(:bob) { Fabricate(:user, email: 'bob@example.com', account: Fabricate(:account, username: 'bob', domain: 'example.com', protocol: :activitypub, inbox_url: 'http://example.com/inbox')).account }
  34. before do
  35. FollowRequest.create(account: bob, target_account: sender)
  36. stub_request(:post, bob.inbox_url).to_return(status: 200)
  37. subject.call(bob, sender)
  38. end
  39. it 'removes follow request' do
  40. expect(bob.requested?(sender)).to be false
  41. end
  42. it 'does not create follow relation' do
  43. expect(bob.following?(sender)).to be false
  44. end
  45. it 'sends a reject activity' do
  46. expect(a_request(:post, bob.inbox_url)).to have_been_made.once
  47. end
  48. end
  49. end