Sha256: 0f9de75538ec701ba7d0e61890979a97beda5c44aaf6b8452276c7c413770596

Contents?: true

Size: 968 Bytes

Versions: 2

Compression:

Stored size: 968 Bytes

Contents

require 'spec_helper'

module Spree
  describe OrderInventory do
    let(:order) { Order.create }

    subject { OrderInventory.new(order, order.line_items.first) }

    context "same variant within bundle and as regular product" do
      let(:contents) { OrderContents.new(order) }
      let(:guitar) { create(:variant) }
      let(:bass) { create(:variant) }

      let(:bundle) { create(:product) }

      before { bundle.parts.push [guitar, bass] }

      let!(:bundle_item) { contents.add(bundle.master, 5) }
      let!(:guitar_item) { contents.add(guitar, 3) }

      let!(:shipment) { order.create_proposed_shipments.first }

      context "completed order" do
        before { order.touch :completed_at }

        it "removes only units associated with provided line item" do
          expect {
            subject.send(:remove_from_shipment, shipment, 5)
          }.not_to change { bundle_item.inventory_units.count }
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
solidus_product_bundle-1.0.1 spec/models/spree/order_inventory_spec.rb
solidus_product_bundle-1.0.0 spec/models/spree/order_inventory_spec.rb