Permalink
Browse files

Jobs can be re-queued using `Job#recreate`. closes #18

  • Loading branch information...
defunkt committed Dec 8, 2009
1 parent 33c0f8a commit 77a19711acf54cc2d587dea885849ec0c5cfce95
Showing with 16 additions and 0 deletions.
  1. +1 −0 HISTORY.md
  2. +6 −0 lib/resque/job.rb
  3. +9 −0 test/resque_test.rb
View
@@ -6,6 +6,7 @@
* config.ru loads RESQUECONFIG if the ENV variable is set.
* `resque-web` now sets RESQUECONFIG
* Job objects know if they are equal.
+* Jobs can be re-queued using `Job#recreate`
## 1.2.0 (2009-11-25)
View
@@ -81,6 +81,12 @@ def fail(exception)
:queue => queue
end
+ # Creates an identical job, essentially placing this job back on
+ # the queue.
+ def recreate
+ self.class.create(queue, payload_class, *args)
+ end
+
# String representation
def inspect
obj = @payload
View
@@ -25,6 +25,15 @@
assert_equal '/tmp', job.args[1]
end
+ test "can re-queue jobs" do
+ Resque::Job.create(:jobs, 'some-job', 20, '/tmp')
+
+ job = Resque.reserve(:jobs)
+ job.recreate
+
+ assert_equal job, Resque.reserve(:jobs)
+ end
+
test "can put jobs on a queue by way of an ivar" do
assert_equal 0, Resque.size(:ivar)
assert Resque.enqueue(SomeIvarJob, 20, '/tmp')

0 comments on commit 77a1971

Please sign in to comment.