How to test that ActiveJob is enqueued?

前端 未结 3 2014
难免孤独
难免孤独 2021-01-21 10:08

I have a create action that calls an ActiveJob if the record is successfully saved.

def create
  @object = Object.new(importer_params)
  respond_to do |format|
         


        
3条回答
  •  时光说笑
    2021-01-21 10:35

    If you need to check that your job has been enqueued several times, you can now do this:

    expect {
      3.times { HelloJob.perform_later }
    }.to have_enqueued_job(HelloJob).at_least(2).times
    

提交回复
热议问题