aboutsummaryrefslogblamecommitdiffstats
path: root/activejob/test/cases/rescue_test.rb
blob: 4fbd27fe6ce6df98e16b6a6ef0bde5b873de7a12 (plain) (tree)
1
2
3
4
5
6
7
8
9






                                                  
                                  
     
 
                                               

                                           
                                                                                                     


                                                   
                       
                                           
                                             
       

     
require 'helper'
require 'jobs/rescue_job'

require 'active_support/core_ext/object/inclusion'

class RescueTest < ActiveSupport::TestCase
  setup do
    Thread.current[:ajbuffer] = []
  end

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

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