remove_from_public_statuses_index_worker_spec.rb 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe RemoveFromPublicStatusesIndexWorker do
  4. describe '#perform' do
  5. let(:account) { Fabricate(:account, indexable: indexable) }
  6. let(:account_id) { account.id }
  7. before do
  8. allow(Account).to receive(:find).with(account_id).and_return(account) unless account.nil?
  9. allow(account).to receive(:remove_from_public_statuses_index!) unless account.nil?
  10. end
  11. context 'when account is not indexable' do
  12. let(:indexable) { false }
  13. it 'removes the account from public statuses index' do
  14. subject.perform(account_id)
  15. expect(account).to have_received(:remove_from_public_statuses_index!)
  16. end
  17. end
  18. context 'when account is indexable' do
  19. let(:indexable) { true }
  20. it 'does not remove the account from public statuses index' do
  21. subject.perform(account_id)
  22. expect(account).to_not have_received(:remove_from_public_statuses_index!)
  23. end
  24. end
  25. context 'when account does not exist' do
  26. let(:account) { nil }
  27. let(:account_id) { 999 }
  28. it 'does not raise an error' do
  29. expect { subject.perform(account_id) }.to_not raise_error
  30. end
  31. end
  32. end
  33. end