Skip to content

Commit

Permalink
Run sentry-resque specs without Rails
Browse files Browse the repository at this point in the history
Tests and fixes getsentry#2243
  • Loading branch information
dentarg committed Feb 17, 2024
1 parent 325c644 commit 81159ad
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 6 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/sentry_resque_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ jobs:
bundle install --jobs 4 --retry 3
bundle exec rake
- name: Run specs with Rails
env:
BUNDLE_GEMFILE: Gemfile_with_rails.rb
RUBYOPT: ${{ matrix.options.rubyopt }}
run: |
bundle install --jobs 4 --retry 3
bundle exec rake
- name: Upload Coverage
if: ${{ matrix.options.codecov }}
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d
1 change: 1 addition & 0 deletions sentry-resque/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/_yardoc/
/coverage/
/doc/
Gemfile_with_rails.rb.lock
/pkg/
/spec/reports/
/tmp/
Expand Down
3 changes: 0 additions & 3 deletions sentry-resque/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ git_source(:github) { |name| "https://github.com/#{name}.git" }
# Specify your gem's dependencies in sentry-ruby.gemspec
gemspec
gem "sentry-ruby", path: "../sentry-ruby"
gem "sentry-rails", path: "../sentry-rails"

gem "rails"

# For https://github.com/ruby/psych/issues/655
gem "psych", "5.1.0"
Expand Down
4 changes: 4 additions & 0 deletions sentry-resque/Gemfile_with_rails.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
eval_gemfile File.expand_path("Gemfile", __dir__)

gem "sentry-rails", path: "../sentry-rails"
gem "rails"
6 changes: 5 additions & 1 deletion sentry-resque/lib/sentry/resque.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ def record(queue, worker, payload, &block)

finish_transaction(transaction, 200)
rescue Exception => exception
klass = payload['class'].constantize
klass = if payload['class'].respond_to?(:constantize)
payload['class'].constantize
else
Object.const_get(payload['class'])
end

raise if Sentry.configuration.resque.report_after_job_retries &&
defined?(::Resque::Plugins::Retry) == 'constant' &&
Expand Down
9 changes: 7 additions & 2 deletions sentry-resque/spec/sentry/resque_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,16 @@ def self.perform(msg)
end
end

context "with ActiveJob" do
rails_gems = begin
require "rails"
require "active_job"
require "sentry-rails"
true
rescue LoadError
false
end

context "with ActiveJob" do
class AJMessageJob < ActiveJob::Base
self.queue_adapter = :resque

Expand Down Expand Up @@ -290,7 +295,7 @@ def perform
expect(event[:contexts][:"Active-Job"][:job_class]).to eq("AJFailedJob")
end
end
end
end if rails_gems
end


Expand Down

0 comments on commit 81159ad

Please sign in to comment.