unblock_service_spec.rb 1.0 KB

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