Sha256: e3887970682cc70b4c46f38266619526325684e446194858e14d1e6616947bce

Contents?: true

Size: 959 Bytes

Versions: 7

Compression:

Stored size: 959 Bytes

Contents

require 'job_uniqueness/spec_helper'

RSpec.describe CanvasSync::JobUniqueness::OnConflict::Reschedule do
  include_context "on_conflict specs"
  include_examples "OnConflict is compatible with", %i[while_executing]

  it "calls reenqueue" do
    expect(lock_context).to receive(:reenqueue) do |*args, **kwargs|
      expect(Thread.current[:unique_jobs_previous_jid]).to be_present
    end
    on_conflict.call
  end

  it "reschedules successfully" do
    TestWorker.unique_job_options.merge!({ strategy: :until_and_while_executing, on_conflict: { enqueue: :raise, perform: :reschedule }})

    lock_context.handle_lifecycle!(:enqueue) {}
    lock_context.handle_lifecycle!(:perform) {}

    lock_context2 = CanvasSync::JobUniqueness::Compat::Sidekiq::SidekiqLockContext.new({ jid: 'j2', queue: 'default', job_clazz: 'TestWorker'}, job_instance: {})
    lock_context2.handle_lifecycle!(:enqueue) {}
    lock_context2.handle_lifecycle!(:perform) {}
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
canvas_sync-0.22.0.beta7 spec/job_uniqueness/on_conflict/reschedule_spec.rb
canvas_sync-0.22.0.beta6 spec/job_uniqueness/on_conflict/reschedule_spec.rb
canvas_sync-0.22.0.beta5 spec/job_uniqueness/on_conflict/reschedule_spec.rb
canvas_sync-0.22.0.beta4 spec/job_uniqueness/on_conflict/reschedule_spec.rb
canvas_sync-0.22.0.beta3 spec/job_uniqueness/on_conflict/reschedule_spec.rb
canvas_sync-0.22.0.beta2 spec/job_uniqueness/on_conflict/reschedule_spec.rb
canvas_sync-0.22.0.beta1 spec/job_uniqueness/on_conflict/reschedule_spec.rb