1
0

unblock_domain_service_spec.rb 1.6 KB

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