1
0

unblock_service_spec.rb 1005 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe UnblockService do
  4. subject { described_class.new }
  5. let(:sender) { Fabricate(:account, username: 'alice') }
  6. describe 'local' do
  7. let(:bob) { Fabricate(:account) }
  8. before { sender.block!(bob) }
  9. it 'destroys the blocking relation' do
  10. subject.call(sender, bob)
  11. expect(sender)
  12. .to_not be_blocking(bob)
  13. end
  14. end
  15. describe 'remote ActivityPub' do
  16. let(:bob) { Fabricate(:account, username: 'bob', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') }
  17. before do
  18. sender.block!(bob)
  19. stub_request(:post, 'http://example.com/inbox').to_return(status: 200)
  20. end
  21. it 'destroys the blocking relation and sends unblock activity', :inline_jobs do
  22. subject.call(sender, bob)
  23. expect(sender)
  24. .to_not be_blocking(bob)
  25. expect(a_request(:post, 'http://example.com/inbox'))
  26. .to have_been_made.once
  27. end
  28. end
  29. end