aboutsummaryrefslogtreecommitdiffstats
path: root/activejob/test/cases/rescue_test.rb
blob: 250ab6867167b2333587cfec1ee6b288f452a686 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require 'helper'
require 'jobs/rescue_job'

require 'active_support/core_ext/object/inclusion'

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

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

  test 'let through unhandled perform exception' do
    job = RescueJob.new
    assert_raises(RescueJob::OtherError) do
      job.execute(SecureRandom.uuid, "other")
    end
  end
end