Skip to content

Commit

Permalink
Grab shipment line items via inventory units
Browse files Browse the repository at this point in the history
The previous implementations doesn't make sense anymore on the current
split shipments scenario. Can't see a reason why tracking inventory
levels config should influence whether or not the line item should be
returned
  • Loading branch information
huoxito committed Nov 29, 2013
1 parent 22c97d6 commit 7718bdb
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 37 deletions.
6 changes: 1 addition & 5 deletions core/app/models/spree/shipment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,7 @@ def manifest
end

def line_items
if order.complete? and Spree::Config.track_inventory_levels
order.line_items.select { |li| !li.should_track_inventory? || inventory_units.pluck(:variant_id).include?(li.variant_id) }
else
order.line_items
end
inventory_units.includes(:line_item).map(&:line_item).uniq
end

def finalize!
Expand Down
32 changes: 0 additions & 32 deletions core/spec/models/spree/shipment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -203,38 +203,6 @@
end
end

context "when track_inventory is false" do
before { Spree::Config.set track_inventory_levels: false }
after { Spree::Config.set track_inventory_levels: true }

it "should not use the line items from order when track_inventory_levels is false" do
line_items = [mock_model(Spree::LineItem)]
order.stub complete?: true
order.stub line_items: line_items
shipment.line_items.should == line_items
end
end

context "when variant inventory tracking is false" do
it "should include line items without inventory if variant inventory tracking is off" do
line_items = [mock_model(Spree::LineItem)]
line_items.each { |li| li.stub should_track_inventory?: false }
order.stub complete?: true
order.stub line_items: line_items
shipment.line_items.should == line_items
end

it "should not include line items without inventory if variant inventory tracking is on" do
line_items = [mock_model(Spree::LineItem)]
line_items.each { |li| li.stub should_track_inventory?: true }
order.stub complete?: true
order.stub line_items: line_items
shipment.line_items.should == []
end
end



context "when order is completed" do
after { Spree::Config.set track_inventory_levels: true }

Expand Down

0 comments on commit 7718bdb

Please sign in to comment.