Sha256: 2e087076b282dbdbb4e17fc5ffbbeb2b1b20a62cafbf8bc3661eee8794ceb921

Contents?: true

Size: 1.57 KB

Versions: 15

Compression:

Stored size: 1.57 KB

Contents

RSpec.describe SolidusBactracs::Shipment::PendingApiSyncQuery do
  describe '.apply' do
    context 'when dealing with shipments that were never synced' do
      it 'returns the shipments that are within the threshold' do
        stub_configuration(api_sync_threshold: 10.minutes)
        shipment = create(:order_ready_to_ship).shipments.first.tap do |s|
          s.order.update_columns(updated_at: 9.minutes.ago)
        end
        create(:order_ready_to_ship).shipments.first.tap do |s|
          s.order.update_columns(updated_at: 11.minutes.ago)
        end

        expect(described_class.apply(Spree::Shipment.all)).to match_array([shipment])
      end
    end

    context 'when dealing with shipments that were already synced' do
      it 'returns the shipments that are within the threshold and pending a re-sync' do
        stub_configuration(api_sync_threshold: 10.minutes)
        shipment = create(:order_ready_to_ship).shipments.first.tap do |s|
          s.order.update_columns(updated_at: 7.minutes.ago)
          s.update_columns(bactracs_synced_at: 8.minutes.ago)
        end
        create(:order_ready_to_ship).shipments.first.tap do |s|
          s.order.update_columns(updated_at: 9.minutes.ago)
          s.update_columns(bactracs_synced_at: 8.minutes.ago)
        end
        create(:order_ready_to_ship).shipments.first.tap do |s|
          s.order.update_columns(updated_at: 11.minutes.ago)
          s.update_columns(bactracs_synced_at: 10.minutes.ago)
        end

        expect(described_class.apply(Spree::Shipment.all)).to match_array([shipment])
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
solidus_bactracs-4.0.1 spec/queries/solidus_bactracs/shipment/pending_api_sync_query_spec.rb
solidus_bactracs-4.0.0 spec/queries/solidus_bactracs/shipment/pending_api_sync_query_spec.rb
solidus_bactracs-3.5.2 spec/queries/solidus_bactracs/shipment/pending_api_sync_query_spec.rb
solidus_bactracs-3.5.1 spec/queries/solidus_bactracs/shipment/pending_api_sync_query_spec.rb
solidus_bactracs-3.5.0 spec/queries/solidus_bactracs/shipment/pending_api_sync_query_spec.rb
solidus_bactracs-3.4.0 spec/queries/solidus_bactracs/shipment/pending_api_sync_query_spec.rb
solidus_bactracs-3.3.2 spec/queries/solidus_bactracs/shipment/pending_api_sync_query_spec.rb
solidus_bactracs-3.3.1 spec/queries/solidus_bactracs/shipment/pending_api_sync_query_spec.rb
solidus_bactracs-3.3.0 spec/queries/solidus_bactracs/shipment/pending_api_sync_query_spec.rb
solidus_bactracs-3.2.2 spec/queries/solidus_bactracs/shipment/pending_api_sync_query_spec.rb
solidus_bactracs-3.2.1 spec/queries/solidus_bactracs/shipment/pending_api_sync_query_spec.rb
solidus_bactracs-3.2.0 spec/queries/solidus_bactracs/shipment/pending_api_sync_query_spec.rb
solidus_bactracs-3.1.2 spec/queries/solidus_bactracs/shipment/pending_api_sync_query_spec.rb
solidus_bactracs-3.1.1 spec/queries/solidus_bactracs/shipment/pending_api_sync_query_spec.rb
solidus_bactracs-3.1.0 spec/queries/solidus_bactracs/shipment/pending_api_sync_query_spec.rb