Permalink
Browse files

fix dequeue for empty

`dequeue` should return `0` when no queue exist or queue is empty.
  • Loading branch information...
otoyo authored and yaauie committed May 2, 2014
1 parent 79aa295 commit 3b47581cee223481232855a3dd0ec9d9c0c5258f
Showing with 3 additions and 1 deletion.
  1. +1 −1 lib/resque/job.rb
  2. +2 −0 test/legacy/resque_test.rb
View
@@ -103,7 +103,7 @@ def self.destroy(queue, klass, *args)
redis.del(temp_queue).to_i
end
- destroyed_count.inject(:+)
+ destroyed_count.inject(0, :+)
end
# Find jobs from a queue. Expects a string queue name, a
@@ -58,6 +58,8 @@
it "can remove jobs from a queue by way of an ivar" do
assert_equal 0, Resque.size(:ivar)
+ assert_equal 0, Resque.dequeue(SomeIvarJob)
+
assert Resque.enqueue(SomeIvarJob, 20, '/tmp')
assert Resque.enqueue(SomeIvarJob, 30, '/tmp')
assert Resque.enqueue(SomeIvarJob, 20, '/tmp')

0 comments on commit 3b47581

Please sign in to comment.