Sha256: 907a26678cd820bb258d9d19a1d0aa4ec8738cc28a984f99d35f0be8bfd8422c

Contents?: true

Size: 1.16 KB

Versions: 126

Compression:

Stored size: 1.16 KB

Contents

require 'integration_helper'

# Simple test of adding jobs to the current batch
# Batches:
# - Overall (TestWoker) + Another worker

class AnotherWorker
  include Sidekiq::Worker

  def perform
    Sidekiq.logger.info "Another Worker"
  end
end

class TestWorker
  include Sidekiq::Worker

  def perform
    Sidekiq.logger.info "Test Worker"
    if bid
      batch.jobs do
        AnotherWorker.perform_async
      end
    end
  end
end

class MyCallback
  def on_success(status, options)
    Sidekiq.logger.info "Success #{options} #{status.data}"
  end
  alias_method :multi, :on_success

  def on_complete(status, options)
    Sidekiq.logger.info "Complete #{options} #{status.data}"
  end
end

batch = CanvasSync::JobBatches::Batch.new
batch.description = 'Test batch'
batch.callback_queue = :default
batch.on(:success, 'MyCallback#on_success', to: 'success@gmail.com')
batch.on(:success, 'MyCallback#multi', to: 'success@gmail.com')
batch.on(:complete, MyCallback, to: 'complete@gmail.com')

batch.jobs do
  10.times do
    TestWorker.perform_async
  end
end
puts CanvasSync::JobBatches::Batch::Status.new(batch.bid).data

dump_redis_keys

Sidekiq::Worker.drain_all

dump_redis_keys

Version data entries

126 entries across 126 versions & 1 rubygems

Version Path
canvas_sync-0.22.9 spec/job_batching/integration/integration.rb
canvas_sync-0.22.8 spec/job_batching/integration/integration.rb
canvas_sync-0.22.6 spec/job_batching/integration/integration.rb
canvas_sync-0.22.5 spec/job_batching/integration/integration.rb
canvas_sync-0.22.4 spec/job_batching/integration/integration.rb
canvas_sync-0.22.3 spec/job_batching/integration/integration.rb
canvas_sync-0.22.2 spec/job_batching/integration/integration.rb
canvas_sync-0.22.1 spec/job_batching/integration/integration.rb
canvas_sync-0.22.0 spec/job_batching/integration/integration.rb
canvas_sync-0.22.0.beta8 spec/job_batching/integration/integration.rb
canvas_sync-0.22.0.beta7 spec/job_batching/integration/integration.rb
canvas_sync-0.22.0.beta6 spec/job_batching/integration/integration.rb
canvas_sync-0.22.0.beta5 spec/job_batching/integration/integration.rb
canvas_sync-0.22.0.beta4 spec/job_batching/integration/integration.rb
canvas_sync-0.22.0.beta3 spec/job_batching/integration/integration.rb
canvas_sync-0.22.0.beta2 spec/job_batching/integration/integration.rb
canvas_sync-0.22.0.beta1 spec/job_batching/integration/integration.rb
canvas_sync-0.21.1 spec/job_batching/integration/integration.rb
canvas_sync-0.21.1.beta1 spec/job_batching/integration/integration.rb
canvas_sync-0.21.0 spec/job_batching/integration/integration.rb