diff --git a/app/models/spree/stock/packer.rb b/app/models/spree/stock/packer.rb index 2dc5a67b9c..9dab72909c 100644 --- a/app/models/spree/stock/packer.rb +++ b/app/models/spree/stock/packer.rb @@ -1,9 +1,11 @@ +# frozen_string_literal: true + module Spree module Stock class Packer attr_reader :stock_location, :order, :splitters, :package_factory - def initialize(stock_location, order, splitters=[Splitter::Base]) + def initialize(stock_location, order, splitters = [Splitter::Base]) @stock_location = stock_location @order = order @splitters = splitters @@ -25,8 +27,8 @@ module Spree next unless stock_location.stock_item(line_item.variant) on_hand, backordered = stock_location.fill_status(line_item.variant, line_item.quantity) - package.add line_item.variant, on_hand, :on_hand if on_hand > 0 - package.add line_item.variant, backordered, :backordered if backordered > 0 + package.add line_item.variant, on_hand, :on_hand if on_hand.positive? + package.add line_item.variant, backordered, :backordered if backordered.positive? else package.add line_item.variant, line_item.quantity, :on_hand end diff --git a/spec/models/spree/stock/packer_spec.rb b/spec/models/spree/stock/packer_spec.rb index 34259e1c43..e29c7b92f6 100644 --- a/spec/models/spree/stock/packer_spec.rb +++ b/spec/models/spree/stock/packer_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' module Spree @@ -33,7 +35,7 @@ module Spree end it 'variants are added as backordered without enough on_hand' do - stock_location.should_receive(:fill_status).exactly(5).times.and_return([2,3]) + stock_location.should_receive(:fill_status).exactly(5).times.and_return([2, 3]) package = subject.default_package package.on_hand.size.should eq 5