From 08342ad40c1b92caf873282190efe8533a7d6e2e Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Wed, 21 Feb 2024 12:13:11 -0500 Subject: [PATCH] Add basic coverage for `AfterUnallowDomainService` class (#29324) --- .../after_unallow_domain_service_spec.rb | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 spec/services/after_unallow_domain_service_spec.rb diff --git a/spec/services/after_unallow_domain_service_spec.rb b/spec/services/after_unallow_domain_service_spec.rb new file mode 100644 index 0000000000..717c42b931 --- /dev/null +++ b/spec/services/after_unallow_domain_service_spec.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe AfterUnallowDomainService do + describe '#call' do + context 'with accounts for a domain' do + let!(:account) { Fabricate(:account, domain: 'host.example') } + let!(:test_account) { Fabricate(:account, domain: 'test.example') } + let(:service_double) { instance_double(DeleteAccountService, call: true) } + + before { allow(DeleteAccountService).to receive(:new).and_return(service_double) } + + it 'calls the delete service for accounts from the relevant domain' do + subject.call 'test.example' + + expect(service_double) + .to_not have_received(:call).with(account, reserve_username: false) + expect(service_double) + .to have_received(:call).with(test_account, reserve_username: false) + end + end + end +end