Sha256: 422c404dcaea1257b8a156166299cd3dac137af28cfa1ae7bb6d33ff6e803482

Contents?: true

Size: 1.16 KB

Versions: 32

Compression:

Stored size: 1.16 KB

Contents

require 'spec_helper'

module Spree
  module Stock
    describe InventoryUnitBuilder, type: :model do
      let(:line_item_1) { build(:line_item) }
      let(:line_item_2) { build(:line_item, quantity: 2) }
      let(:order) { build(:order, line_items: [line_item_1, line_item_2]) }

      subject { InventoryUnitBuilder.new(order) }

      describe "#units" do
        it "returns an inventory unit for each quantity for the order's line items" do
          units = subject.units
          expect(units.count).to eq 3
          expect(units.first.line_item).to eq line_item_1
          expect(units.first.variant).to eq line_item_1.variant

          expect(units[1].line_item).to eq line_item_2
          expect(units[1].variant).to eq line_item_2.variant

          expect(units[2].line_item).to eq line_item_2
          expect(units[2].variant).to eq line_item_2.variant
        end

        it "builds the inventory units as pending" do
          expect(subject.units.map(&:pending).uniq).to eq [true]
        end

        it "associates the inventory units to the order" do
          expect(subject.units.map(&:order).uniq).to eq [order]
        end
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
solidus_core-2.3.1 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-2.2.2 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-2.1.1 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-2.0.3 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-1.4.2 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-1.3.2 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-2.3.0 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-2.3.0.rc3 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-2.3.0.rc2 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-2.3.0.rc1 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-2.3.0.beta1 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-2.0.2 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-1.4.1 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-2.2.1 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-2.2.0 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-2.2.0.rc1 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-2.2.0.beta1 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-2.1.0 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-2.1.0.rc1 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-2.0.1 spec/models/spree/stock/inventory_unit_builder_spec.rb