|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
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" |
75 | 4 |
|
76 | 5 | RSpec.describe "without Sentry initialized", type: :job do |
77 | 6 | it "runs job" do |
|
0 commit comments