Sha256: b318a9454db07b2b0538f6df6f4d2c34aeeadbd0b8b488939208bf7bca089dad

Contents?: true

Size: 1003 Bytes

Versions: 1

Compression:

Stored size: 1003 Bytes

Contents

require 'spec_helper'

module Spree
  describe OrderInventory do
    let!(:store) { create :store }
    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

1 entries across 1 versions & 1 rubygems

Version Path
solidus_product_assembly-1.0.0 spec/models/spree/order_inventory_spec.rb