Permalink
Browse files

Merge pull request #76 from seomoz/fix-74

Fix #74 using the "bandaid" solution
  • Loading branch information...
2 parents 7a2956e + ecbbf5a commit 34faabc7ee64fbaa2ec19b0b48fb4a2b870640c3 @myronmarston myronmarston committed Jan 31, 2013
Showing with 10 additions and 2 deletions.
  1. +3 −1 lib/qless/worker.rb
  2. +1 −1 spec/unit/job_spec.rb
  3. +6 −0 spec/unit/worker_spec.rb
View
@@ -144,6 +144,8 @@ def unpause_processing
def retryable_exception_classes(job)
return [] unless job.klass.respond_to?(:retryable_exception_classes)
job.klass.retryable_exception_classes
+ rescue NameError => exn
+ []
end
def try_complete(job)
@@ -169,7 +171,7 @@ def around_perform(job)
}
def fail_job(job, error)
- group = "#{job.klass}:#{error.class}"
+ group = "#{job.klass_name}:#{error.class}"
message = "#{error.message}\n\n#{error.backtrace.join("\n")}"
log "Got #{group} failure from #{job.inspect}"
job.fail(group, message)
View
@@ -39,7 +39,7 @@ class Nested
stub_const("MyJobClass", Class.new)
job = Job.build(client, ::MyJobClass, data: {})
hide_const("MyJobClass")
- expect { job.klass }.to raise_error(/constant MyJobClass/)
+ expect { job.klass }.to raise_error(NameError, /constant MyJobClass/)
end
end
View
@@ -94,6 +94,12 @@ class MyJobClass; end
worker.perform(job)
end
+ it 'fails the job if the job class is invalid or not found' do
+ hide_const('Qless::MyJobClass')
+ job.should_receive(:fail)
+ expect { worker.perform(job) }.not_to raise_error
+ end
+
it 'does not complete the job if the job logic itself changes the state of it (e.g. moves it to a new queue)' do
MyJobClass.stub(:perform) { |j| j.move("other") }
job.should_not_receive(:complete)

0 comments on commit 34faabc

Please sign in to comment.