diff --git a/lib/sidekiq/api.rb b/lib/sidekiq/api.rb index d9e2cde3..b50c200a 100644 --- a/lib/sidekiq/api.rb +++ b/lib/sidekiq/api.rb @@ -279,6 +279,10 @@ module Sidekiq end end + def find_job(jid) + self.find{ |j| j.jid == jid } + end + def delete(score, jid = nil) if jid elements = Sidekiq.redis do |conn| diff --git a/test/test_api.rb b/test/test_api.rb index 26593fa2..90407b5f 100644 --- a/test/test_api.rb +++ b/test/test_api.rb @@ -179,6 +179,13 @@ class TestApi < MiniTest::Unit::TestCase assert_equal 0, q.size end + it 'can find job by id' do + q = Sidekiq::Queue.new + job_id = ApiWorker.perform_in(100, 1, 'jason') + job = Sidekiq::ScheduledSet.new.find_job(job_id) + assert job + end + it 'can clear a queue' do q = Sidekiq::Queue.new 2.times { ApiWorker.perform_async(1, 'mike') }