Skip to content

Commit 16e761d

Browse files
committed
Use test jobs defined in support file
1 parent 328ec93 commit 16e761d

2 files changed

Lines changed: 7 additions & 72 deletions

File tree

sentry-rails/spec/sentry/rails/activejob_spec.rb

Lines changed: 1 addition & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,6 @@
11
# frozen_string_literal: true
22

3-
require "spec_helper"
4-
require "active_job/railtie"
5-
6-
class NormalJob < ActiveJob::Base
7-
def perform
8-
"foo"
9-
end
10-
end
11-
12-
class FailedJob < ActiveJob::Base
13-
self.logger = nil
14-
15-
class TestError < RuntimeError
16-
end
17-
18-
def perform
19-
a = 1
20-
b = 0
21-
raise TestError, "Boom!"
22-
end
23-
end
24-
25-
class FailedWithExtraJob < FailedJob
26-
def perform
27-
Sentry.get_current_scope.set_extras(foo: :bar)
28-
super
29-
end
30-
end
31-
32-
class JobWithArgument < ActiveJob::Base
33-
def perform(*args, integer:, post:, **options)
34-
raise "foo"
35-
end
36-
end
37-
38-
class QueryPostJob < ActiveJob::Base
39-
self.logger = nil
40-
41-
def perform
42-
Post.all.to_a
43-
end
44-
end
45-
46-
class RescuedActiveJob < FailedWithExtraJob
47-
rescue_from TestError, with: :rescue_callback
48-
49-
def rescue_callback(error); end
50-
end
51-
52-
class ProblematicRescuedActiveJob < FailedWithExtraJob
53-
rescue_from TestError, with: :rescue_callback
54-
55-
def rescue_callback(error)
56-
raise "foo"
57-
end
58-
end
59-
60-
class NormalJobWithCron < NormalJob
61-
include Sentry::Cron::MonitorCheckIns
62-
sentry_monitor_check_ins
63-
end
64-
65-
class FailedJobWithCron < FailedJob
66-
include Sentry::Cron::MonitorCheckIns
67-
sentry_monitor_check_ins slug: "failed_job", monitor_config: Sentry::Cron::MonitorConfig.from_crontab("5 * * * *")
68-
end
69-
70-
class FailedJobWithRetryOn < FailedJob
71-
if respond_to? :retry_on
72-
retry_on StandardError, attempts: 3, wait: 0
73-
end
74-
end
3+
require_relative "../../support/test_jobs"
754

765
RSpec.describe "without Sentry initialized", type: :job do
776
it "runs job" do

sentry-rails/spec/support/test_jobs.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,9 @@ class FailedJobWithCron < FailedJob
6565
include Sentry::Cron::MonitorCheckIns
6666
sentry_monitor_check_ins slug: "failed_job", monitor_config: Sentry::Cron::MonitorConfig.from_crontab("5 * * * *")
6767
end
68+
69+
class FailedJobWithRetryOn < FailedJob
70+
if respond_to? :retry_on
71+
retry_on StandardError, attempts: 3, wait: 0
72+
end
73+
end

0 commit comments

Comments
 (0)