Sha256: cd0f7293ec2a33ec34b364a26e01e7022a5bf694b64473b79ecdb5df5c1e4740

Contents?: true

Size: 1008 Bytes

Versions: 16

Compression:

Stored size: 1008 Bytes

Contents

require 'spec_helper'

require 'active_support/rescuable'

describe Rollbar::ActiveJob do
  class TestJob
    # To mix in rescue_from
    include ActiveSupport::Rescuable
    include Rollbar::ActiveJob

    attr_reader :job_id

    def perform(exception, job_id)
      @job_id = job_id
      # ActiveJob calls rescue_with_handler when a job raises an exception
      rescue_with_handler(exception) || raise(exception)
    end
  end

  before { reconfigure_notifier }

  let(:exception) { StandardError.new('oh no') }
  let(:job_id) { "123" }

  it "reports the error to Rollbar" do
    expected_params = {
      :job => "TestJob",
      :job_id => job_id,
      :use_exception_level_filters => true
    }
    expect(Rollbar).to receive(:error).with(exception, expected_params)
    TestJob.new.perform(exception, job_id) rescue nil
  end

  it "reraises the error so the job backend can handle the failure and retry" do
    expect { TestJob.new.perform(exception, job_id) }.to raise_error exception
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
rollbar-2.17.0 spec/rollbar/plugins/active_job_spec.rb
rollbar-2.16.4 spec/rollbar/plugins/active_job_spec.rb
rollbar-2.16.3 spec/rollbar/plugins/active_job_spec.rb
rollbar-2.16.2 spec/rollbar/plugins/active_job_spec.rb
rollbar-2.16.0 spec/rollbar/plugins/active_job_spec.rb
rollbar-2.15.6 spec/rollbar/plugins/active_job_spec.rb
rollbar-2.15.5 spec/rollbar/plugins/active_job_spec.rb
rollbar-2.15.4 spec/rollbar/plugins/active_job_spec.rb
rollbar-2.15.3 spec/rollbar/plugins/active_job_spec.rb
rollbar-2.15.2 spec/rollbar/plugins/active_job_spec.rb
rollbar-2.15.1 spec/rollbar/plugins/active_job_spec.rb
rollbar-2.15.0 spec/rollbar/plugins/active_job_spec.rb
rollbar-2.14.1 spec/rollbar/plugins/active_job_spec.rb
rollbar-2.14.0 spec/rollbar/plugins/active_job_spec.rb
rollbar-2.13.3 spec/rollbar/plugins/active_job_spec.rb
rollbar-2.13.2 spec/rollbar/plugins/active_job_spec.rb