Sha256: 96bb44fcc8bd42f4939436ac18bdf64d4c668fe56e42cf7341122b03e23e6a2b

Contents?: true

Size: 909 Bytes

Versions: 17

Compression:

Stored size: 909 Bytes

Contents

require 'job_uniqueness/spec_helper'

RSpec.shared_context "lock strategy specs" do |strategy:|
  include_context 'with TestWorker'

  before(:each) { TestWorker.unique_job_options[:strategy] = strategy }

  let(:context1) { CanvasSync::JobUniqueness::LockContext.new({ jid: 'j1', queue: 'default', job_clazz: 'TestWorker'}) }
  let(:context2) { CanvasSync::JobUniqueness::LockContext.new({ jid: 'j2', queue: 'default', job_clazz: 'TestWorker'}) }

  let(:process_one) { described_class.new(context1) }
  let(:process_two) { described_class.new(context2) }
end

RSpec.shared_examples "a lock implementation" do
  it "is unlocked when done" do
    process_one.on_enqueue {}
    did_lock = process_one.locked?

    process_one.on_perform {}
    did_lock ||= process_one.locked?

    expect(did_lock).to be_truthy

    process_one.batch_callback(:success, nil)
    expect(process_one).not_to be_locked
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
canvas_sync-0.22.9 spec/job_uniqueness/support/lock_strategy.rb
canvas_sync-0.22.8 spec/job_uniqueness/support/lock_strategy.rb
canvas_sync-0.22.6 spec/job_uniqueness/support/lock_strategy.rb
canvas_sync-0.22.5 spec/job_uniqueness/support/lock_strategy.rb
canvas_sync-0.22.4 spec/job_uniqueness/support/lock_strategy.rb
canvas_sync-0.22.3 spec/job_uniqueness/support/lock_strategy.rb
canvas_sync-0.22.2 spec/job_uniqueness/support/lock_strategy.rb
canvas_sync-0.22.1 spec/job_uniqueness/support/lock_strategy.rb
canvas_sync-0.22.0 spec/job_uniqueness/support/lock_strategy.rb
canvas_sync-0.22.0.beta8 spec/job_uniqueness/support/lock_strategy.rb
canvas_sync-0.22.0.beta7 spec/job_uniqueness/support/lock_strategy.rb
canvas_sync-0.22.0.beta6 spec/job_uniqueness/support/lock_strategy.rb
canvas_sync-0.22.0.beta5 spec/job_uniqueness/support/lock_strategy.rb
canvas_sync-0.22.0.beta4 spec/job_uniqueness/support/lock_strategy.rb
canvas_sync-0.22.0.beta3 spec/job_uniqueness/support/lock_strategy.rb
canvas_sync-0.22.0.beta2 spec/job_uniqueness/support/lock_strategy.rb
canvas_sync-0.22.0.beta1 spec/job_uniqueness/support/lock_strategy.rb