manage_sessions_jobs_spec.rb 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe BackgroundServices::Service::ManageSessionsJobs do
  4. let(:manager) { BackgroundServices.new(BackgroundServices::ServiceConfig.configuration_from_env(env)) }
  5. let(:env) { {} }
  6. describe '.skip?' do
  7. context 'when ProcessSessionsJob is missing' do
  8. let(:manager) { BackgroundServices.new([]) }
  9. it 'skips' do
  10. expect(described_class.skip?(manager:)).to be(true)
  11. end
  12. end
  13. context 'when ProcessSessionsJob is disabled' do
  14. let(:env) do
  15. {
  16. 'ZAMMAD_PROCESS_SESSIONS_JOBS_DISABLE' => 'true',
  17. 'ZAMMAD_PROCESS_SESSIONS_JOBS_WORKERS' => '2',
  18. }
  19. end
  20. it 'skips' do
  21. expect(described_class.skip?(manager:)).to be(true)
  22. end
  23. end
  24. context 'when ProcessSessionsJob is active and threaded (default)' do
  25. it 'skips' do
  26. expect(described_class.skip?(manager:)).to be(true)
  27. end
  28. end
  29. context 'when ProcessSessionsJob is active and forking' do
  30. let(:env) { { 'ZAMMAD_PROCESS_SESSIONS_JOBS_WORKERS' => '2' } }
  31. it 'skips' do
  32. expect(described_class.skip?(manager:)).to be(false)
  33. end
  34. end
  35. end
  36. end