File tree Expand file tree Collapse file tree 3 files changed +26
-4
lines changed Expand file tree Collapse file tree 3 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ def perform
6464 finished
6565 else
6666 failed_with ( result . error )
67+ raise result . error
6768 end
6869 ensure
6970 job . unblock_next_blocked_job
Original file line number Diff line number Diff line change @@ -22,7 +22,9 @@ class SolidQueue::ClaimedExecutionTest < ActiveSupport::TestCase
2222 job = claimed_execution . job
2323
2424 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
2628 end
2729
2830 assert_not job . reload . finished?
@@ -37,10 +39,12 @@ class SolidQueue::ClaimedExecutionTest < ActiveSupport::TestCase
3739 test "job failures are reported via Rails error subscriber" do
3840 subscriber = ErrorBuffer . new
3941
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" )
4245
43- claimed_execution . perform
46+ claimed_execution . perform
47+ end
4448 end
4549
4650 assert_equal 1 , subscriber . errors . count
Original file line number Diff line number Diff line change @@ -67,6 +67,23 @@ class WorkerTest < ActiveSupport::TestCase
6767 SolidQueue . on_thread_error = original_on_thread_error
6868 end
6969
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+
7087 test "claim and process more enqueued jobs than the pool size allows to process at once" do
7188 5 . times do |i |
7289 StoreResultJob . perform_later ( :paused , pause : 0.1 . second )
You can’t perform that action at this time.
0 commit comments