Sha256: 58ecf76443609e7764aa238b62fd556775658f7f7a24e5c7593fa66368dc08aa

Contents?: true

Size: 1.51 KB

Versions: 15

Compression:

Stored size: 1.51 KB

Contents

require 'job_uniqueness/spec_helper'

RSpec.describe CanvasSync::JobUniqueness::UniqueJobCommon do
  describe ".unlock!" do
    include_context "with TestWorker"

    it "unlocks the lock with a specific JID" do
      jid = TestWorker.perform_async
      lctx = CanvasSync::JobUniqueness::LockContext.new({ jid: jid, queue: 'default', job_clazz: 'TestWorker'})
      lstrat = lctx.lock_strategy
      lsmith = lstrat.send(:locksmith)
      expect(lsmith.locked?).to be_truthy

      TestWorker.unlock!(jid, queue: 'default')
      expect(lsmith.locked?).to be_falsey
    end

    it "unlocks the lock without a specific JID" do
      jid = TestWorker.perform_async
      lctx = CanvasSync::JobUniqueness::LockContext.new({ jid: jid, queue: 'default', job_clazz: 'TestWorker'})
      lstrat = lctx.lock_strategy
      lsmith = lstrat.send(:locksmith)
      expect(lsmith.locked?).to be_truthy

      TestWorker.unlock!(queue: 'default')
      expect(lsmith.locked?).to be_falsey
    end

    it "unlocks the lock matching parameters" do
      args = [1, 2, 3]
      jid = TestWorker.perform_async(*args)

      lctx = CanvasSync::JobUniqueness::LockContext.new({ jid: jid, queue: 'default', job_clazz: 'TestWorker', args: args})
      lstrat = lctx.lock_strategy
      lsmith = lstrat.send(:locksmith)
      expect(lsmith.locked?).to be_truthy

      TestWorker.unlock!(queue: 'default')
      expect(lsmith.locked?).to be_truthy

      TestWorker.unlock!(queue: 'default', args: args)
      expect(lsmith.locked?).to be_falsey
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

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