Sha256: 16e93414bf44a681b54913748a0f1e32488fa7a43b22072dfe49bfd84722ee14

Contents?: true

Size: 1.24 KB

Versions: 5

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

describe Delayed::JobGroups::CompleteStuckJobGroupsJob do
  describe "#perform" do
    let(:job) { described_class.new }

    let!(:blocked) { create(:job_group, blocked: true) }
    let!(:not_queueing_complete) { create(:job_group, queueing_complete: false) }
    let!(:ready_without_jobs) { create(:job_group, queueing_complete: true, blocked: false) }
    let!(:ready_with_jobs) do
      create(:job_group, queueing_complete: true, blocked: false).tap do |job_group|
        create(:delayed_job, job_group: job_group)
      end
    end

    before do
      allow(Delayed::JobGroups::JobGroup).to receive(:check_for_completion)
    end

    it "checks all relevant job groups for completion" do
      job.perform

      expect(Delayed::JobGroups::JobGroup).to have_received(:check_for_completion)
                                                .once
                                                .with(ready_without_jobs.id, skip_pending_jobs_check: true)
    end
  end

  describe "#enqueue" do
    before do
      allow(Delayed::Job).to receive(:enqueue)
    end

    it "enqueues the job" do
      described_class.enqueue

      expect(Delayed::Job).to have_received(:enqueue).with(instance_of(described_class))
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
delayed_job_groups_plugin-0.12.0 spec/delayed/job_groups/complete_stuck_job_groups_job_spec.rb
delayed_job_groups_plugin-0.11.0 spec/delayed/job_groups/complete_stuck_job_groups_job_spec.rb
delayed_job_groups_plugin-0.10.1 spec/delayed/job_groups/complete_stuck_job_groups_job_spec.rb
delayed_job_groups_plugin-0.10.0 spec/delayed/job_groups/complete_stuck_job_groups_job_spec.rb
delayed_job_groups_plugin-0.9.0 spec/delayed/job_groups/complete_stuck_job_groups_job_spec.rb