Sha256: 89737c928ebec2933d73033e7e2f82617fd84eab1dd32244851c2b6783592483

Contents?: true

Size: 1.06 KB

Versions: 48

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

require 'rails_helper'

module Spree
  module Stock
    RSpec.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
      end
    end
  end
end

Version data entries

48 entries across 48 versions & 2 rubygems

Version Path
solidus_core-2.10.5 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-2.10.3 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-2.10.2 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-2.9.6 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-2.8.6 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-2.10.1 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-2.9.5 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-2.10.0 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-2.9.4 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-2.6.6 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-2.7.4 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-2.8.5 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-2.9.3 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-2.9.2 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-2.10.0.beta1 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-2.7.3 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-2.6.5 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-2.9.1 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-2.9.0 spec/models/spree/stock/inventory_unit_builder_spec.rb
solidus_core-2.9.0.rc.1 spec/models/spree/stock/inventory_unit_builder_spec.rb