remove_from_followers_service_spec.rb 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe RemoveFromFollowersService do
  4. subject { described_class.new }
  5. let(:bob) { Fabricate(:account, username: 'bob') }
  6. describe 'local' do
  7. let(:sender) { Fabricate(:account, username: 'alice') }
  8. before { Follow.create(account: sender, target_account: bob) }
  9. it 'does not create follow relation' do
  10. subject.call(bob, sender)
  11. expect(bob)
  12. .to_not be_followed_by(sender)
  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. end
  21. it 'does not create follow relation and sends reject activity', :inline_jobs do
  22. subject.call(bob, sender)
  23. expect(bob)
  24. .to_not be_followed_by(sender)
  25. expect(a_request(:post, sender.inbox_url))
  26. .to have_been_made.once
  27. end
  28. end
  29. end