remove_from_follwers_service_spec.rb 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. require 'rails_helper'
  2. RSpec.describe RemoveFromFollowersService, type: :service do
  3. let(:bob) { Fabricate(:account, username: 'bob') }
  4. subject { RemoveFromFollowersService.new }
  5. describe 'local' do
  6. let(:sender) { Fabricate(:account, username: 'alice') }
  7. before do
  8. Follow.create(account: sender, target_account: bob)
  9. subject.call(bob, sender)
  10. end
  11. it 'does not create follow relation' do
  12. expect(bob.followed_by?(sender)).to be false
  13. end
  14. end
  15. describe 'remote ActivityPub' do
  16. let(:sender) { Fabricate(:account, username: 'alice', domain: 'example.com', protocol: :activitypub, inbox_url: 'http://example.com/inbox') }
  17. before do
  18. Follow.create(account: sender, target_account: bob)
  19. stub_request(:post, sender.inbox_url).to_return(status: 200)
  20. subject.call(bob, sender)
  21. end
  22. it 'does not create follow relation' do
  23. expect(bob.followed_by?(sender)).to be false
  24. end
  25. it 'sends a reject activity' do
  26. expect(a_request(:post, sender.inbox_url)).to have_been_made.once
  27. end
  28. end
  29. end