Skip to content

Commit

Permalink
Jobs can be re-queued using Job#recreate. closes resque#18
Browse files Browse the repository at this point in the history
  • Loading branch information
defunkt committed Dec 8, 2009
1 parent 33c0f8a commit 77a1971
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions HISTORY.md
Expand Up @@ -6,6 +6,7 @@
* config.ru loads RESQUECONFIG if the ENV variable is set. * config.ru loads RESQUECONFIG if the ENV variable is set.
* `resque-web` now sets RESQUECONFIG * `resque-web` now sets RESQUECONFIG
* Job objects know if they are equal. * Job objects know if they are equal.
* Jobs can be re-queued using `Job#recreate`


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


Expand Down
6 changes: 6 additions & 0 deletions lib/resque/job.rb
Expand Up @@ -81,6 +81,12 @@ def fail(exception)
:queue => queue :queue => queue
end 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 # String representation
def inspect def inspect
obj = @payload obj = @payload
Expand Down
9 changes: 9 additions & 0 deletions test/resque_test.rb
Expand Up @@ -25,6 +25,15 @@
assert_equal '/tmp', job.args[1] assert_equal '/tmp', job.args[1]
end 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 test "can put jobs on a queue by way of an ivar" do
assert_equal 0, Resque.size(:ivar) assert_equal 0, Resque.size(:ivar)
assert Resque.enqueue(SomeIvarJob, 20, '/tmp') assert Resque.enqueue(SomeIvarJob, 20, '/tmp')
Expand Down

0 comments on commit 77a1971

Please sign in to comment.