@@ -31,9 +31,8 @@ class ActiveSupport::TestCase
31
31
include ConfigurationTestHelper , ProcessesTestHelper , JobsTestHelper
32
32
33
33
setup do
34
- # Could be cleaner with one several minitest gems, but didn't want to add new dependency
35
34
@_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 )
37
36
end
38
37
39
38
teardown do
@@ -84,21 +83,17 @@ def skip_active_record_query_cache(&block)
84
83
# @param [Exception, Array<Exception>] expected an Exception or an array of Exceptions to ignore
85
84
# @yield Executes the provided block with specified exception(s) silenced
86
85
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
88
89
block . call
89
90
end
90
91
end
91
92
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 )
97
94
-> ( 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 )
102
97
end
103
98
end
104
99
end
0 commit comments