Skip to content

Commit 77a1971

Browse files
committed
Jobs can be re-queued using Job#recreate. closes resque#18
1 parent 33c0f8a commit 77a1971

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

HISTORY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* config.ru loads RESQUECONFIG if the ENV variable is set.
77
* `resque-web` now sets RESQUECONFIG
88
* Job objects know if they are equal.
9+
* Jobs can be re-queued using `Job#recreate`
910

1011
## 1.2.0 (2009-11-25)
1112

lib/resque/job.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ def fail(exception)
8181
:queue => queue
8282
end
8383

84+
# Creates an identical job, essentially placing this job back on
85+
# the queue.
86+
def recreate
87+
self.class.create(queue, payload_class, *args)
88+
end
89+
8490
# String representation
8591
def inspect
8692
obj = @payload

test/resque_test.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@
2525
assert_equal '/tmp', job.args[1]
2626
end
2727

28+
test "can re-queue jobs" do
29+
Resque::Job.create(:jobs, 'some-job', 20, '/tmp')
30+
31+
job = Resque.reserve(:jobs)
32+
job.recreate
33+
34+
assert_equal job, Resque.reserve(:jobs)
35+
end
36+
2837
test "can put jobs on a queue by way of an ivar" do
2938
assert_equal 0, Resque.size(:ivar)
3039
assert Resque.enqueue(SomeIvarJob, 20, '/tmp')

0 commit comments

Comments
 (0)