unblock_domain_service_spec.rb 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe UnblockDomainService 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. context 'with severity of silence' do
  12. before { domain_block.update(severity: :silence) }
  13. it 'unsilences accounts and removes block' do
  14. subject.call(domain_block)
  15. expect_deleted_domain_block
  16. expect(silenced.reload.silenced?).to be false
  17. expect(suspended.reload.suspended?).to be true
  18. expect(independently_suspended.reload.suspended?).to be true
  19. expect(independently_silenced.reload.silenced?).to be true
  20. end
  21. end
  22. context 'with severity of suspend' do
  23. before { domain_block.update(severity: :suspend) }
  24. it 'unsuspends accounts and removes block' do
  25. subject.call(domain_block)
  26. expect_deleted_domain_block
  27. expect(suspended.reload.suspended?).to be false
  28. expect(silenced.reload.silenced?).to be false
  29. expect(independently_suspended.reload.suspended?).to be true
  30. expect(independently_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