remove_from_followers_service_spec.rb 1.1 KB

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