cache_clear_job_spec.rb 816 B

12345678910111213141516171819202122232425262728293031323334353637
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe CacheClearJob do
  4. around do |example|
  5. old_cache = Rails.cache
  6. Rails.cache = cache
  7. example.run
  8. ensure
  9. Rails.cache = old_cache
  10. end
  11. before do
  12. allow(Rails.cache).to receive(:cleanup).and_call_original
  13. end
  14. context 'when Cache is FileStore' do
  15. let(:cache) { ActiveSupport::Cache::FileStore.new 'path' }
  16. it 'does cleanup' do
  17. described_class.perform_now
  18. expect(Rails.cache).to have_received :cleanup
  19. end
  20. end
  21. context 'when Cache is Memcached' do
  22. let(:cache) { ActiveSupport::Cache::MemCacheStore.new }
  23. it 'does not cleanup' do
  24. described_class.perform_now
  25. expect(Rails.cache).not_to have_received :cleanup
  26. end
  27. end
  28. end