Skip to content
This repository

Fix #74 using the "bandaid" solution #76

Merged
merged 1 commit into from about 1 year ago

2 participants

Ben Kirzhner Myron Marston
Ben Kirzhner
Collaborator

No description provided.

Myron Marston myronmarston merged commit 34faabc into from January 31, 2013
Myron Marston myronmarston closed this January 31, 2013
Myron Marston myronmarston deleted the branch January 31, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Jan 31, 2013
Ben Kirzhner Fixes #74 ecbbf5a
This page is out of date. Refresh to see the latest.
4  lib/qless/worker.rb
@@ -144,6 +144,8 @@ def unpause_processing
144 144
     def retryable_exception_classes(job)
145 145
       return [] unless job.klass.respond_to?(:retryable_exception_classes)
146 146
       job.klass.retryable_exception_classes
  147
+    rescue NameError => exn
  148
+      []
147 149
     end
148 150
 
149 151
     def try_complete(job)
@@ -169,7 +171,7 @@ def around_perform(job)
169 171
     }
170 172
 
171 173
     def fail_job(job, error)
172  
-      group = "#{job.klass}:#{error.class}"
  174
+      group = "#{job.klass_name}:#{error.class}"
173 175
       message = "#{error.message}\n\n#{error.backtrace.join("\n")}"
174 176
       log "Got #{group} failure from #{job.inspect}"
175 177
       job.fail(group, message)
2  spec/unit/job_spec.rb
@@ -39,7 +39,7 @@ class Nested
39 39
         stub_const("MyJobClass", Class.new)
40 40
         job = Job.build(client, ::MyJobClass, data: {})
41 41
         hide_const("MyJobClass")
42  
-        expect { job.klass }.to raise_error(/constant MyJobClass/)
  42
+        expect { job.klass }.to raise_error(NameError, /constant MyJobClass/)
43 43
       end
44 44
     end
45 45
 
6  spec/unit/worker_spec.rb
@@ -94,6 +94,12 @@ class MyJobClass; end
94 94
           worker.perform(job)
95 95
         end
96 96
 
  97
+        it 'fails the job if the job class is invalid or not found' do
  98
+          hide_const('Qless::MyJobClass')
  99
+          job.should_receive(:fail)
  100
+          expect { worker.perform(job) }.not_to raise_error
  101
+        end
  102
+
97 103
         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
98 104
           MyJobClass.stub(:perform) { |j| j.move("other") }
99 105
           job.should_not_receive(:complete)
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.