diff --git a/CHANGELOG.md b/CHANGELOG.md index dfe723de..10a8f40e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,14 @@ Changelog ========= +## TBD + +### Fixes + +* Fix Resque integration when failure backend is already `Resque::Failure::Multiple` + | [#803](https://github.com/bugsnag/bugsnag-ruby/pull/803) + | [sj26](https://github.com/sj26) + ## v6.26.0 (19 July 2023) ### Enhancements diff --git a/features/fixtures/rails_integrations/app/config/application.rb b/features/fixtures/rails_integrations/app/config/application.rb index f28492e9..79984d89 100644 --- a/features/fixtures/rails_integrations/app/config/application.rb +++ b/features/fixtures/rails_integrations/app/config/application.rb @@ -1,3 +1,14 @@ +# reproduce #803 by setting Resque's backend to 'Multiple' before our Resque +# integration runs +# see https://github.com/bugsnag/bugsnag-ruby/pull/803 +require "resque" +require "resque/failure/redis" +require "resque/failure/multiple" + +Resque::Failure::Multiple.classes = [Resque::Failure::Redis] +Resque::Failure.backend = Resque::Failure::Multiple +# end #803 reproduction + require_relative 'boot' require "rails" diff --git a/lib/bugsnag/integrations/resque.rb b/lib/bugsnag/integrations/resque.rb index 8d997f80..6ec4652d 100644 --- a/lib/bugsnag/integrations/resque.rb +++ b/lib/bugsnag/integrations/resque.rb @@ -21,7 +21,7 @@ def self.add_failure_backend return if ::Resque::Failure.backend == self # Ensure resque is using a "Multiple" failure backend - unless ::Resque::Failure.backend < ::Resque::Failure::Multiple + unless ::Resque::Failure.backend <= ::Resque::Failure::Multiple original_backend = ::Resque::Failure.backend ::Resque::Failure.backend = ::Resque::Failure::Multiple ::Resque::Failure.backend.classes ||= [] diff --git a/spec/integrations/resque_spec.rb b/spec/integrations/resque_spec.rb index 4716b33a..d09e2155 100644 --- a/spec/integrations/resque_spec.rb +++ b/spec/integrations/resque_spec.rb @@ -31,7 +31,7 @@ def require(path) #Auto-load failure backend backend = double('backend') allow(::Resque::Failure).to receive(:backend).and_return(backend) - expect(backend).to receive(:<).and_return(nil) + expect(backend).to receive(:<=).and_return(nil) expect(::Resque::Failure).to receive(:backend=).with(::Resque::Failure::Multiple) classes = double('classes') allow(backend).to receive(:classes).and_return(classes)