@@ -22,15 +22,6 @@ def perform(exception, job_id)
22
22
end
23
23
end
24
24
25
- class TestMailer < ActionMailer ::Base
26
- attr_accessor :arguments
27
-
28
- def test_email ( *_arguments )
29
- error = StandardError . new ( 'oh no' )
30
- raise ( error )
31
- end
32
- end
33
-
34
25
before { reconfigure_notifier }
35
26
36
27
let ( :exception ) { StandardError . new ( 'oh no' ) }
@@ -52,19 +43,6 @@ def test_email(*_arguments)
52
43
end . to raise_error exception
53
44
end
54
45
55
- it 'scrubs all arguments if job has `log_arguments` disabled' do
56
- allow ( TestJob ) . to receive ( :log_arguments? ) . and_return ( false )
57
-
58
- expected_params [ :job_id ] = job_id
59
- expected_params [ :arguments ] = [ '******' , '******' , '******' ]
60
- expect ( Rollbar ) . to receive ( :error ) . with ( exception , expected_params )
61
- begin
62
- TestJob . new ( 1 , 2 , 3 ) . perform ( exception , job_id )
63
- rescue StandardError
64
- nil
65
- end
66
- end
67
-
68
46
it 'job is created' do
69
47
ActiveJob ::Base . queue_adapter = :test
70
48
expect do
@@ -88,6 +66,15 @@ def test_email(*_arguments)
88
66
end
89
67
90
68
context 'using ActionMailer::DeliveryJob' , :if => Gem ::Version . new ( Rails . version ) < Gem ::Version . new ( '6.0' ) do
69
+ class TestMailer < ActionMailer ::Base
70
+ attr_accessor :arguments
71
+
72
+ def test_email ( *_arguments )
73
+ error = StandardError . new ( 'oh no' )
74
+ raise ( error )
75
+ end
76
+ end
77
+
91
78
include ActiveJob ::TestHelper if defined? ( ActiveJob ::TestHelper )
92
79
93
80
it_behaves_like 'an ActiveMailer plugin'
@@ -118,6 +105,19 @@ def test_email(*_arguments)
118
105
end
119
106
end
120
107
108
+ it 'scrubs all arguments if job has `log_arguments` disabled' do
109
+ allow ( TestJob ) . to receive ( :log_arguments? ) . and_return ( false )
110
+
111
+ expected_params [ :job_id ] = job_id
112
+ expected_params [ :arguments ] = [ '******' , '******' , '******' ]
113
+ expect ( Rollbar ) . to receive ( :error ) . with ( exception , expected_params )
114
+ begin
115
+ TestJob . new ( 1 , 2 , 3 ) . perform ( exception , job_id )
116
+ rescue StandardError
117
+ nil
118
+ end
119
+ end
120
+
121
121
it 'scrubs job arguments hash' do
122
122
Rollbar . configure do |config |
123
123
config . scrub_fields |= [ 'user_id' ]
@@ -155,12 +155,22 @@ def test_email(*_arguments)
155
155
end
156
156
157
157
context 'using ActionMailer::MailDeliveryJob' , :if => Gem ::Version . new ( Rails . version ) >= Gem ::Version . new ( '6.0' ) do
158
+ class ParentMailer < ActionMailer ::Base ; end
159
+
160
+ class TestMailer2 < ParentMailer
161
+ def test_email ( *_arguments )
162
+ error = StandardError . new ( 'oh no' )
163
+ raise ( error )
164
+ end
165
+ end
166
+
158
167
include ActiveJob ::TestHelper if defined? ( ActiveJob ::TestHelper )
159
168
160
169
let ( :expected_params ) do
161
170
{
162
171
:job => 'TestJob' ,
163
- :use_exception_level_filters => true
172
+ :use_exception_level_filters => true ,
173
+ :action => 'test_email'
164
174
}
165
175
end
166
176
@@ -169,13 +179,12 @@ def test_email(*_arguments)
169
179
it 'reports the error to Rollbar' do
170
180
expected_params . delete ( :job )
171
181
172
- # In 6+, the re-raise in the plugin will cause the rescue_from to be called twice.
173
- expect ( Rollbar ) . to receive ( :error ) . twice . with ( kind_of ( StandardError ) ,
182
+ expect ( Rollbar ) . to receive ( :error ) . with ( kind_of ( StandardError ) ,
174
183
hash_including ( expected_params ) )
175
184
176
185
perform_enqueued_jobs do
177
186
begin
178
- TestMailer . test_email ( argument ) . deliver_later
187
+ TestMailer2 . test_email ( argument ) . deliver_later
179
188
rescue StandardError => e
180
189
nil
181
190
end
0 commit comments