block_service_spec.rb 937 B

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