@@ -31,9 +31,8 @@ class ActiveSupport::TestCase
3131 include ConfigurationTestHelper , ProcessesTestHelper , JobsTestHelper
3232
3333 setup do
34- # Could be cleaner with one several minitest gems, but didn't want to add new dependency
3534 @_on_thread_error = SolidQueue . on_thread_error
36- SolidQueue . on_thread_error = silent_on_thread_error_for ( ExpectedTestError )
35+ SolidQueue . on_thread_error = silent_on_thread_error_for ( ExpectedTestError , @_on_thread_error )
3736 end
3837
3938 teardown do
@@ -84,21 +83,17 @@ def skip_active_record_query_cache(&block)
8483 # @param [Exception, Array<Exception>] expected an Exception or an array of Exceptions to ignore
8584 # @yield Executes the provided block with specified exception(s) silenced
8685 def silence_on_thread_error_for ( expected , &block )
87- SolidQueue . with ( on_thread_error : silent_on_thread_error_for ( expected ) ) do
86+ current_proc = SolidQueue . on_thread_error
87+
88+ SolidQueue . with ( on_thread_error : silent_on_thread_error_for ( expected , current_proc ) ) do
8889 block . call
8990 end
9091 end
9192
92- # Does not call on_thread_error for expected exceptions
93- # @param [Exception, Array<Exception>] expected an Exception or an array of Exceptions to ignore
94- def silent_on_thread_error_for ( expected )
95- current_proc = SolidQueue . on_thread_error
96-
93+ def silent_on_thread_error_for ( exceptions , on_thread_error )
9794 -> ( exception ) do
98- expected_exceptions = Array ( expected )
99-
100- unless expected_exceptions . any? { exception . instance_of? ( _1 ) }
101- current_proc . call ( exception )
95+ unless Array ( exceptions ) . any? { |e | exception . instance_of? ( e ) }
96+ on_thread_error . call ( exception )
10297 end
10398 end
10499 end
0 commit comments