Skip to content

Commit

Permalink
CI: test retry_stopped.active_job
Browse files Browse the repository at this point in the history
Enhance the ActiveJob notifications test suite by adding a test for the
`retry_stopped.active_job` notification that Rails 6+ fires when it
stops retrying to perform a job.

resolves #1764
  • Loading branch information
fallwith committed Sep 22, 2023
1 parent 698c839 commit 1393412
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
require 'new_relic/agent/instrumentation/active_job_subscriber'

module NewRelic::Agent::Instrumentation
class RetryMe < StandardError; end
class DiscardMe < StandardError; end
class RetryMe < StandardError; end
class RetryStopped < StandardError; end

class TestJob < ActiveJob::Base
retry_on RetryMe
retry_on RetryStopped, attempts: 1

discard_on DiscardMe

Expand Down Expand Up @@ -82,7 +84,16 @@ def test_discard_active_job
end
end

# TODO: test for retry_stopped.active_job
def test_retry_stopped_active_job
skip 'Notification requires Rails v6+' unless Gem::Version.new(Rails::VERSION::STRING) >= Gem::Version.new('6.0')

in_transaction do |txn|
assert_raises(RetryStopped) do
TestJob.perform_now(RetryStopped)
end
validate_transaction(txn, 'retry_stopped')
end
end

private

Expand Down

0 comments on commit 1393412

Please sign in to comment.