active_job.rb 860 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. module ZammadActiveJobHelper
  2. delegate :enqueued_jobs, :performed_jobs, to: :queue_adapter
  3. def queue_adapter
  4. ::ActiveJob::Base.queue_adapter
  5. end
  6. def clear_jobs
  7. enqueued_jobs.clear
  8. performed_jobs.clear
  9. ActiveJobLock.destroy_all
  10. end
  11. end
  12. RSpec.configure do |config|
  13. activate_for = {
  14. type: :job, # actual Job examples
  15. performs_jobs: true, # examples performing Jobs
  16. }
  17. activate_for.each do |key, value|
  18. config.include ZammadActiveJobHelper, key => value
  19. config.include RSpec::Rails::JobExampleGroup, key => value
  20. config.around(:each, key => value) do |example|
  21. default_queue_adapter = ::ActiveJob::Base.queue_adapter
  22. ::ActiveJob::Base.queue_adapter = :test
  23. clear_jobs
  24. example.run
  25. ::ActiveJob::Base.queue_adapter = default_queue_adapter
  26. end
  27. end
  28. end