Skip to content

Commit 05bcde2

Browse files
committed
Raise when a job class does not respond to perform.
This will fail the job and the failure will show up in the Resque UI.
1 parent 1ab1d57 commit 05bcde2

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

HISTORY.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.2.0 (2009-??-??)
2+
3+
* Raise when a job class does not respond to `perform`.
4+
15
## 1.1.0 (2009-11-04)
26

37
* Bugfix: Broken ERB tag in failure UI

lib/resque/job.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ def self.reserve(queue)
5858
# Calls #perform on the class given in the payload with the
5959
# arguments given in the payload.
6060
def perform
61-
return unless payload_class && payload_class.respond_to?(:perform)
6261
args ? payload_class.perform(*args) : payload_class.perform
6362
end
6463

test/worker_test.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,15 @@
9191
end
9292
end
9393

94+
test "fails if a job class has no `perform` method" do
95+
worker = Resque::Worker.new(:perform_less)
96+
Resque::Job.create(:perform_less, Object)
97+
98+
assert_equal 0, Resque::Failure.count
99+
worker.work(0)
100+
assert_equal 1, Resque::Failure.count
101+
end
102+
94103
test "inserts itself into the 'workers' list on startup" do
95104
@worker.work(0) do
96105
assert_equal @worker, Resque.workers[0]

0 commit comments

Comments
 (0)