unblock_service_spec.rb 985 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. require 'rails_helper'
  2. RSpec.describe UnblockService, type: :service do
  3. let(:sender) { Fabricate(:account, username: 'alice') }
  4. subject { UnblockService.new }
  5. describe 'local' do
  6. let(:bob) { Fabricate(:account) }
  7. before do
  8. sender.block!(bob)
  9. subject.call(sender, bob)
  10. end
  11. it 'destroys the blocking relation' do
  12. expect(sender.blocking?(bob)).to be false
  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. subject.call(sender, bob)
  21. end
  22. it 'destroys the blocking relation' do
  23. expect(sender.blocking?(bob)).to be false
  24. end
  25. it 'sends an unblock activity' do
  26. expect(a_request(:post, 'http://example.com/inbox')).to have_been_made.once
  27. end
  28. end
  29. end