File tree 3 files changed +26
-4
lines changed
3 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ def perform
64
64
finished
65
65
else
66
66
failed_with ( result . error )
67
+ raise result . error
67
68
end
68
69
ensure
69
70
job . unblock_next_blocked_job
Original file line number Diff line number Diff line change @@ -22,7 +22,9 @@ class SolidQueue::ClaimedExecutionTest < ActiveSupport::TestCase
22
22
job = claimed_execution . job
23
23
24
24
assert_difference -> { SolidQueue ::ClaimedExecution . count } => -1 , -> { SolidQueue ::FailedExecution . count } => 1 do
25
- claimed_execution . perform
25
+ assert_raises RuntimeError do
26
+ claimed_execution . perform
27
+ end
26
28
end
27
29
28
30
assert_not job . reload . finished?
@@ -37,10 +39,12 @@ class SolidQueue::ClaimedExecutionTest < ActiveSupport::TestCase
37
39
test "job failures are reported via Rails error subscriber" do
38
40
subscriber = ErrorBuffer . new
39
41
40
- with_error_subscriber ( subscriber ) do
41
- claimed_execution = prepare_and_claim_job RaisingJob . perform_later ( RuntimeError , "B" )
42
+ assert_raises RuntimeError do
43
+ with_error_subscriber ( subscriber ) do
44
+ claimed_execution = prepare_and_claim_job RaisingJob . perform_later ( RuntimeError , "B" )
42
45
43
- claimed_execution . perform
46
+ claimed_execution . perform
47
+ end
44
48
end
45
49
46
50
assert_equal 1 , subscriber . errors . count
Original file line number Diff line number Diff line change @@ -67,6 +67,23 @@ class WorkerTest < ActiveSupport::TestCase
67
67
SolidQueue . on_thread_error = original_on_thread_error
68
68
end
69
69
70
+ test "errors on claimed executions are reported via Rails error subscriber" do
71
+ subscriber = ErrorBuffer . new
72
+ Rails . error . subscribe ( subscriber )
73
+
74
+ RaisingJob . perform_later ( RuntimeError , "B" )
75
+
76
+ @worker . start
77
+
78
+ wait_for_jobs_to_finish_for ( 1 . second )
79
+ @worker . wake_up
80
+
81
+ assert_equal 1 , subscriber . errors . count
82
+ assert_equal "This is a RuntimeError exception" , subscriber . messages . first
83
+ ensure
84
+ Rails . error . unsubscribe ( subscriber ) if Rails . error . respond_to? ( :unsubscribe )
85
+ end
86
+
70
87
test "claim and process more enqueued jobs than the pool size allows to process at once" do
71
88
5 . times do |i |
72
89
StoreResultJob . perform_later ( :paused , pause : 0.1 . second )
You can’t perform that action at this time.
0 commit comments