unblock_domain_service_spec.rb 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. let!(:independently_suspended) { Fabricate(:account, domain: 'example.com', suspended_at: 1.hour.ago) }
  7. let!(:independently_silenced) { Fabricate(:account, domain: 'example.com', silenced_at: 1.hour.ago) }
  8. let!(:domain_block) { Fabricate(:domain_block, domain: 'example.com') }
  9. let!(:silenced) { Fabricate(:account, domain: 'example.com', silenced_at: domain_block.created_at) }
  10. let!(:suspended) { Fabricate(:account, domain: 'example.com', suspended_at: domain_block.created_at) }
  11. it 'unsilences accounts and removes block' do
  12. domain_block.update(severity: :silence)
  13. subject.call(domain_block)
  14. expect_deleted_domain_block
  15. expect(silenced.reload.silenced?).to be false
  16. expect(suspended.reload.suspended?).to be true
  17. expect(independently_suspended.reload.suspended?).to be true
  18. expect(independently_silenced.reload.silenced?).to be true
  19. end
  20. it 'unsuspends accounts and removes block' do
  21. domain_block.update(severity: :suspend)
  22. subject.call(domain_block)
  23. expect_deleted_domain_block
  24. expect(suspended.reload.suspended?).to be false
  25. expect(silenced.reload.silenced?).to be false
  26. expect(independently_suspended.reload.suspended?).to be true
  27. expect(independently_silenced.reload.silenced?).to be true
  28. end
  29. end
  30. def expect_deleted_domain_block
  31. expect { domain_block.reload }.to raise_error(ActiveRecord::RecordNotFound)
  32. end
  33. end