1
0

reject_follow_service_spec.rb 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe RejectFollowService do
  4. subject { described_class.new }
  5. let(:sender) { Fabricate(:account, username: 'alice') }
  6. describe 'local' do
  7. let(:bob) { Fabricate(:account) }
  8. before { FollowRequest.create(account: bob, target_account: sender) }
  9. it 'removes follow request and does not create relation' do
  10. subject.call(bob, sender)
  11. expect(bob)
  12. .to_not be_requested(sender)
  13. expect(bob)
  14. .to_not be_following(sender)
  15. end
  16. end
  17. describe 'remote ActivityPub' do
  18. let(:bob) { Fabricate(:account, username: 'bob', domain: 'example.com', protocol: :activitypub, inbox_url: 'http://example.com/inbox') }
  19. before do
  20. FollowRequest.create(account: bob, target_account: sender)
  21. stub_request(:post, bob.inbox_url).to_return(status: 200)
  22. end
  23. it 'removes follow request, does not create relation, sends reject activity', :inline_jobs do
  24. subject.call(bob, sender)
  25. expect(bob)
  26. .to_not be_requested(sender)
  27. expect(bob)
  28. .to_not be_following(sender)
  29. expect(a_request(:post, bob.inbox_url))
  30. .to have_been_made.once
  31. end
  32. end
  33. end