1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activejob/test/support/integration/adapters/qu.rb

39 lines
838 B
Ruby
Raw Normal View History

2014-08-18 03:19:41 -04:00
module QuJobsManager
def setup
require 'qu-rails'
require 'qu-redis'
ActiveJob::Base.queue_adapter = :qu
2015-03-05 16:41:14 -05:00
ENV['REDISTOGO_URL'] = "redis://127.0.0.1:6379/12"
2014-08-18 03:19:41 -04:00
backend = Qu::Backend::Redis.new
backend.namespace = "active_jobs_int_test"
Qu.backend = backend
Qu.logger = Rails.logger
Qu.interval = 0.5
unless can_run?
puts "Cannot run integration tests for qu. To be able to run integration tests for qu you need to install and start redis.\n"
exit
end
end
def clear_jobs
Qu.clear "integration_tests"
end
def start_workers
@thread = Thread.new { Qu::Worker.new("integration_tests").start }
end
def stop_workers
@thread.kill
end
def can_run?
begin
Qu.backend.connection.client.connect
rescue
2014-08-18 03:19:41 -04:00
return false
end
true
end
end