Sha256: a64ef5033006bc0c450b21f53cbb3c14dad3b24dfe3dd3681d7b71d69491b6aa

Contents?: true

Size: 1.21 KB

Versions: 43

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

require 'rails_helper'

module Spree
  module Stock
    RSpec.describe Differentiator, type: :model do
      let(:variant1) { mock_model(Variant) }
      let(:variant2) { mock_model(Variant) }

      let(:line_item1) { build(:line_item, variant: variant1, quantity: 2) }
      let(:line_item2) { build(:line_item, variant: variant2, quantity: 2) }

      let(:stock_location) { mock_model(StockLocation) }

      let(:inventory_unit1) { build(:inventory_unit, variant: variant1, line_item: line_item1) }
      let(:inventory_unit2) { build(:inventory_unit, variant: variant2, line_item: line_item2) }

      let(:order) { mock_model(Order, line_items: [line_item1, line_item2]) }

      let(:package1) do
        Package.new(stock_location).tap { |p| p.add(inventory_unit1) }
      end

      let(:package2) do
        Package.new(stock_location).tap { |p| p.add(inventory_unit2) }
      end

      let(:packages) { [package1, package2] }

      subject { Differentiator.new(order, packages) }

      it { is_expected.to be_missing }

      it 'calculates the missing items' do
        expect(subject.missing[variant1]).to eq 1
        expect(subject.missing[variant2]).to eq 1
      end
    end
  end
end

Version data entries

43 entries across 43 versions & 2 rubygems

Version Path
solidus_core-2.9.6 spec/models/spree/stock/differentiator_spec.rb
solidus_core-2.8.6 spec/models/spree/stock/differentiator_spec.rb
solidus_core-2.9.5 spec/models/spree/stock/differentiator_spec.rb
solidus_core-2.9.4 spec/models/spree/stock/differentiator_spec.rb
solidus_core-2.6.6 spec/models/spree/stock/differentiator_spec.rb
solidus_core-2.7.4 spec/models/spree/stock/differentiator_spec.rb
solidus_core-2.8.5 spec/models/spree/stock/differentiator_spec.rb
solidus_core-2.9.3 spec/models/spree/stock/differentiator_spec.rb
solidus_core-2.9.2 spec/models/spree/stock/differentiator_spec.rb
solidus_core-2.10.0.beta1 spec/models/spree/stock/differentiator_spec.rb
solidus_core-2.7.3 spec/models/spree/stock/differentiator_spec.rb
solidus_core-2.6.5 spec/models/spree/stock/differentiator_spec.rb
solidus_core-2.9.1 spec/models/spree/stock/differentiator_spec.rb
solidus_core-2.9.0 spec/models/spree/stock/differentiator_spec.rb
solidus_core-2.9.0.rc.1 spec/models/spree/stock/differentiator_spec.rb
solidus_core-2.8.4 spec/models/spree/stock/differentiator_spec.rb
solidus_core-2.8.3 spec/models/spree/stock/differentiator_spec.rb
solidus_core-2.7.2 spec/models/spree/stock/differentiator_spec.rb
solidus_core-2.6.4 spec/models/spree/stock/differentiator_spec.rb
solidus_core-2.8.2 spec/models/spree/stock/differentiator_spec.rb