You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1.0 KiB

  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(:user, email: 'bob@example.com', account: Fabricate(:account, username: 'bob')).account }
  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(:user, email: 'bob@example.com', account: Fabricate(:account, username: 'bob', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox')).account }
  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