block_service_spec.rb 971 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe BlockService, type: :service do
  4. subject { described_class.new }
  5. let(:sender) { Fabricate(:account, username: 'alice') }
  6. describe 'local' do
  7. let(:bob) { Fabricate(:account, username: 'bob') }
  8. before do
  9. subject.call(sender, bob)
  10. end
  11. it 'creates a blocking relation' do
  12. expect(sender.blocking?(bob)).to be true
  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. stub_request(:post, 'http://example.com/inbox').to_return(status: 200)
  19. subject.call(sender, bob)
  20. end
  21. it 'creates a blocking relation' do
  22. expect(sender.blocking?(bob)).to be true
  23. end
  24. it 'sends a block activity' do
  25. expect(a_request(:post, 'http://example.com/inbox')).to have_been_made.once
  26. end
  27. end
  28. end