sessions_jobs.rb 995 B

1234567891011121314151617181920212223242526272829303132
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. RSpec.configure do |config|
  3. config.before(type: :system) do |example|
  4. sessions_jobs_required = example.metadata.fetch(:sessions_jobs, false)
  5. next if !sessions_jobs_required
  6. allow_any_instance_of(Sessions::Backend::Base).to receive(:to_run?).and_return(true)
  7. end
  8. config.around(:each, type: :system) do |example|
  9. sessions_jobs_required = example.metadata.fetch(:sessions_jobs, false)
  10. if sessions_jobs_required
  11. sessions_jobs_thread = Thread.new do
  12. # Try to work around a problem with ActiveRecord::StatementInvalid: Mysql2::Error:
  13. # This connection is in use by: #<Thread:0x000000000e940e18 /builds/zammad/zammad/lib/sessions.rb:533 dead>
  14. ActiveRecord::Base.connection_pool.release_connection
  15. Sessions.jobs
  16. end
  17. end
  18. example.run
  19. next if !sessions_jobs_required
  20. sessions_jobs_thread.exit
  21. sessions_jobs_thread.join
  22. end
  23. end