From 13934122c17db998cae558c1552e9b96a12d760a Mon Sep 17 00:00:00 2001 From: fallwith Date: Fri, 22 Sep 2023 12:31:42 -0700 Subject: [PATCH] CI: test retry_stopped.active_job 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 --- .../rails/active_job_subscriber.rb | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/test/new_relic/agent/instrumentation/rails/active_job_subscriber.rb b/test/new_relic/agent/instrumentation/rails/active_job_subscriber.rb index 61eaa66fc2..8cdfbe51ae 100644 --- a/test/new_relic/agent/instrumentation/rails/active_job_subscriber.rb +++ b/test/new_relic/agent/instrumentation/rails/active_job_subscriber.rb @@ -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 @@ -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