Sha256: 76f3c4719de9cd8e6515d8850a3dd7516b9eb11d80159374eec803f87e801917
Contents?: true
Size: 1.58 KB
Versions: 17
Compression:
Stored size: 1.58 KB
Contents
require 'job_uniqueness/spec_helper' RSpec.describe CanvasSync::JobUniqueness::Compat::ActiveJob do context 'Job Extension' do it 'includes UniqueJobExtension' do expect(ActiveJob::Base < CanvasSync::JobUniqueness::Compat::ActiveJob::JobExtension).to be true end it 'has the ensure_uniqueness method' do expect(ActiveJob::Base.method(:ensure_uniqueness)).to be_present end end context 'Job' do let(:test_job) do Class.new(ActiveJob::Base) do ensure_uniqueness( strategy: :until_executed, ) def perform; end end end before(:each) do stub_const('TestJob', test_job) ActiveJob::Base.queue_adapter = :sidekiq end it 'runs as expected' do strategy = CanvasSync::JobUniqueness::Strategy::UntilExecuted.new(nil) allow_any_instance_of(CanvasSync::JobUniqueness::LockContext).to receive(:lock_strategy) do |lock_context| strategy.instance_variable_set(:@lock_context, lock_context) strategy end allow(CanvasSync::JobUniqueness::Strategy::UntilExecuted).to receive(:new).and_return(strategy) expect(strategy).to receive(:on_enqueue).and_call_original expect(strategy).to receive(:on_perform).and_call_original expect(strategy).to receive(:batch_callback).with(:complete, anything).and_call_original expect(strategy).to receive(:batch_callback).with(:success, anything).and_call_original expect_any_instance_of(test_job).to receive(:perform) Sidekiq::Testing.inline! do test_job.perform_later end end end end
Version data entries
17 entries across 17 versions & 1 rubygems