Sha256: ae688d483d549daccffb6b0cef250b042b073d4631f65a038178623079c6636e
Contents?: true
Size: 1.16 KB
Versions: 15
Compression:
Stored size: 1.16 KB
Contents
# frozen_string_literal: true RSpec.describe SolidusBactracs::Api::ScheduleShipmentSyncsJob do it 'schedules the shipment sync in batches' do stub_configuration(api_batch_size: 2) shipments = create_list(:shipment, 3) relation = instance_double('ActiveRecord::Relation').tap do |r| allow(r).to receive(:find_in_batches) .with(batch_size: 2) .and_yield(shipments[0..1]) .and_yield([shipments.last]) end allow(SolidusBactracs::Shipment::PendingApiSyncQuery).to receive(:apply) .and_return(relation) described_class.perform_now expect(SolidusBactracs::Api::SyncShipmentsJob).to have_been_enqueued.with(shipments[0..1]) expect(SolidusBactracs::Api::SyncShipmentsJob).to have_been_enqueued.with([shipments.last]) end it 'reports any errors to the handler' do error_handler = instance_spy('Proc') stub_configuration(error_handler: error_handler) error = RuntimeError.new('Something went wrong') allow(SolidusBactracs::Shipment::PendingApiSyncQuery).to receive(:apply).and_raise(error) described_class.perform_now expect(error_handler).to have_received(:call).with(error, {}) end end
Version data entries
15 entries across 15 versions & 1 rubygems