Sha256: b0bf4a13ef9eb9704e6dbfaad224dd3be6f40494d621fbd087665be1717293cf

Contents?: true

Size: 1.59 KB

Versions: 8

Compression:

Stored size: 1.59 KB

Contents

RSpec.describe SolidusBacktracs::Shipment::BetweenQuery do
  describe '.apply' do
    it 'returns shipments whose updated_at falls within the given time range' do
      shipment = create(:shipment) { |s| s.update_column(:updated_at, Time.zone.now) }

      result = described_class.apply(
        Spree::Shipment.all,
        from: Time.zone.yesterday,
        to: Time.zone.tomorrow,
      )

      expect(result).to eq([shipment])
    end

    it "returns shipments whose order's updated_at falls within the given time range" do
      order = create(:order) { |o| o.update_column(:updated_at, Time.zone.now) }
      shipment = create(:shipment, order: order)

      result = described_class.apply(
        Spree::Shipment.all,
        from: Time.zone.yesterday,
        to: Time.zone.tomorrow,
      )

      expect(result).to eq([shipment])
    end

    it 'does not return shipments whose updated_at does not fall within the given time range' do
      create(:shipment) { |s| s.update_column(:updated_at, Time.zone.now) }

      result = described_class.apply(
        Spree::Shipment.all,
        from: Time.zone.tomorrow,
        to: Time.zone.tomorrow + 1.day,
      )

      expect(result).to eq([])
    end

    it "does not return shipments whose order's updated_at falls within the given time range" do
      order = create(:order) { |o| o.update_column(:updated_at, Time.zone.now) }
      create(:shipment, order: order)

      result = described_class.apply(
        Spree::Shipment.all,
        from: Time.zone.tomorrow,
        to: Time.zone.tomorrow + 1.day,
      )

      expect(result).to eq([])
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
solidus_bactracs-3.0.0 spec/queries/solidus_backtracs/shipment/between_query_spec.rb
solidus_backtracs-2.2.6 spec/queries/solidus_backtracs/shipment/between_query_spec.rb
solidus_backtracs-2.2.5 spec/queries/solidus_backtracs/shipment/between_query_spec.rb
solidus_backtracs-2.2.4 spec/queries/solidus_backtracs/shipment/between_query_spec.rb
solidus_backtracs-2.2.3 spec/queries/solidus_backtracs/shipment/between_query_spec.rb
solidus_backtracs-2.2.2 spec/queries/solidus_backtracs/shipment/between_query_spec.rb
solidus_backtracs-2.2.1 spec/queries/solidus_backtracs/shipment/between_query_spec.rb
solidus_backtracs-2.2.0 spec/queries/solidus_backtracs/shipment/between_query_spec.rb