unblock_domain_service_spec.rb 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe UnblockDomainService do
  4. subject { described_class.new }
  5. describe 'call' do
  6. before do
  7. @silenced = Fabricate(:account, domain: 'example.com', silenced: true)
  8. @suspended = Fabricate(:account, domain: 'example.com', suspended: true)
  9. @domain_block = Fabricate(:domain_block, domain: 'example.com')
  10. end
  11. context 'without retroactive' do
  12. it 'removes the domain block' do
  13. subject.call(@domain_block, false)
  14. expect_deleted_domain_block
  15. end
  16. end
  17. context 'with retroactive' do
  18. it 'unsilences accounts and removes block' do
  19. @domain_block.update(severity: :silence)
  20. subject.call(@domain_block, true)
  21. expect_deleted_domain_block
  22. expect(@silenced.reload.silenced).to be false
  23. expect(@suspended.reload.suspended).to be true
  24. end
  25. it 'unsuspends accounts and removes block' do
  26. @domain_block.update(severity: :suspend)
  27. subject.call(@domain_block, true)
  28. expect_deleted_domain_block
  29. expect(@suspended.reload.suspended).to be false
  30. expect(@silenced.reload.silenced).to be true
  31. end
  32. end
  33. end
  34. def expect_deleted_domain_block
  35. expect { @domain_block.reload }.to raise_error(ActiveRecord::RecordNotFound)
  36. end
  37. end