Skip to content

Commit

Permalink
Correcting the forward-porting of resque#365
Browse files Browse the repository at this point in the history
as it was (whoopsie!) lost in a rebase.
  • Loading branch information
meatballhat committed Feb 18, 2014
1 parent faee8b4 commit 812b0ed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 9 additions & 0 deletions lib/resque/scheduler/extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,15 @@ def count_all_scheduled_jobs
total_jobs
end

# Discover if a job has been delayed.
# Examples
# Resque.delayed?(MyJob)
# Resque.delayed?(MyJob, id: 1)
# Returns true if the job has been delayed
def delayed?(klass, *args)
!scheduled_at(klass, *args).empty?
end

# Returns delayed jobs schedule timestamp for +klass+, +args+.
def scheduled_at(klass, *args)
search = encode(job_to_hash(klass, args))
Expand Down
8 changes: 4 additions & 4 deletions test/delayed_queue_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -534,10 +534,10 @@
Resque.enqueue_at Time.now + 1, SomeIvarJob
Resque.enqueue_at Time.now + 1, SomeIvarJob, id: 1

assert(Resque.delayed?(SomeIvarJob, id: 1))
assert(!Resque.delayed?(SomeIvarJob, id: 2))
assert(Resque.delayed?(SomeIvarJob))
assert(!Resque.delayed?(SomeJob))
assert Resque.delayed?(SomeIvarJob, id: 1)
assert !Resque.delayed?(SomeIvarJob, id: 2)
assert Resque.delayed?(SomeIvarJob)
assert !Resque.delayed?(SomeJob)

end

Expand Down

0 comments on commit 812b0ed

Please sign in to comment.