Fix simple rubocop issues

This commit is contained in:
Luis Ramos
2020-07-01 16:18:59 +01:00
parent e0f9894b7a
commit ccf928df12
2 changed files with 8 additions and 4 deletions

View File

@@ -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

View File

@@ -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