Sha256: 67c1a904c60e5be026d1c515aae9c55ab1819313a636b116c44a731fcc6ae014

Contents?: true

Size: 1.13 KB

Versions: 13

Compression:

Stored size: 1.13 KB

Contents

require 'helper'
require 'jobs/rescue_job'
require 'models/person'

class RescueTest < ActiveSupport::TestCase
  setup do
    JobBuffer.clear
  end

  test 'rescue perform exception with retry' do
    job = RescueJob.new("david")
    job.perform_now
    assert_equal ["running", "rescued from ArgumentError", "running", "performed beautifully"], JobBuffer.values
  end

  test 'retries other errors' do
    job = RescueJob.new("other")
    assert_raises(RescueJob::OtherError) do
      job.perform_now
      assert_equal ["running", "running"], JobBuffer.values
    end
  end

  test 'rescue from deserialization errors' do
    RescueJob.perform_later Person.new(404)
    assert_includes JobBuffer.values, 'rescued from DeserializationError'
    assert_includes JobBuffer.values, 'DeserializationError original exception was Person::RecordNotFound'
    assert_not_includes JobBuffer.values, 'performed beautifully'
  end

  test "should not wrap DeserializationError in DeserializationError" do
    RescueJob.perform_later [Person.new(404)]
    assert_includes JobBuffer.values, 'DeserializationError original exception was Person::RecordNotFound'
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
activejob-retry-0.6.3 test/cases/rescue_test.rb
activejob-retry-0.6.2 test/cases/rescue_test.rb
activejob-retry-0.6.1 test/cases/rescue_test.rb
activejob-retry-0.6.0 test/cases/rescue_test.rb
activejob-retry-0.5.1 test/cases/rescue_test.rb
activejob-retry-0.5.0 test/cases/rescue_test.rb
activejob-retry-0.4.2 test/cases/rescue_test.rb
activejob-retry-0.4.1 test/cases/rescue_test.rb
activejob-retry-0.4.0 test/cases/rescue_test.rb
activejob-retry-0.3.1 test/cases/rescue_test.rb
activejob-retry-0.3.0 test/cases/rescue_test.rb
activejob-retry-0.2.0 test/cases/rescue_test.rb
activejob-retry-0.1.1 test/cases/rescue_test.rb