Fix simple rubocop issues

This commit is contained in:
Luis Ramos
2020-07-01 16:08:05 +01:00
parent 3ae2877d4e
commit eb13595fd3
3 changed files with 13 additions and 6 deletions

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Used by Prioritizer to adjust item quantities
# see prioritizer_spec for use cases
module Spree
@@ -21,7 +23,7 @@ module Spree
end
def fulfilled?
@need == 0
@need.zero?
end
end
end

View File

@@ -1,9 +1,11 @@
# frozen_string_literal: true
module Spree
module Stock
class Prioritizer
attr_reader :packages, :order
def initialize(order, packages, adjuster_class=Adjuster)
def initialize(order, packages, adjuster_class = Adjuster)
@order = order
@packages = packages
@adjuster_class = adjuster_class
@@ -17,6 +19,7 @@ module Spree
end
private
def adjust_packages
order.line_items.each do |line_item|
adjuster = @adjuster_class.new(line_item.variant, line_item.quantity, :on_hand)
@@ -40,7 +43,7 @@ module Spree
end
def prune_packages
packages.reject! { |pkg| pkg.empty? }
packages.reject!(&:empty?)
end
end
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
module Spree
@@ -57,7 +59,7 @@ module Spree
end
it '1st has some, 2nd has remaining' do
order.line_items[0].stub(:quantity => 5)
order.line_items[0].stub(quantity: 5)
package1 = pack do |package|
package.add variant1, 2, :on_hand
end
@@ -74,7 +76,7 @@ module Spree
end
it '1st has backorder, 2nd has some' do
order.line_items[0].stub(:quantity => 5)
order.line_items[0].stub(quantity: 5)
package1 = pack do |package|
package.add variant1, 5, :backordered
end
@@ -91,7 +93,7 @@ module Spree
end
it '1st has backorder, 2nd has all' do
order.line_items[0].stub(:quantity => 5)
order.line_items[0].stub(quantity: 5)
package1 = pack do |package|
package.add variant1, 3, :backordered
package.add variant2, 1, :on_hand