Fix easy rubocop issues

This commit is contained in:
Luis Ramos
2020-07-10 17:33:25 +01:00
parent 8001e63f77
commit 2070cfd5bb
3 changed files with 12 additions and 9 deletions

View File

@@ -379,7 +379,7 @@ Spree::Order.class_eval do
end
# Update attributes of a record in the database without callbacks, validations etc.
# This was originally a ext to ActiveRecord in Spree but only used for Spree::Order
# This was originally an extension to ActiveRecord in Spree but only used for Spree::Order
def update_attributes_without_callbacks(attributes)
assign_attributes(attributes)
Spree::Order.where(id: id).update_all(attributes)

View File

@@ -52,10 +52,10 @@ module OrderManagement
# Updates the following Order total values:
#
# - payment_total - the total value of all finalized Payments (excluding non-finalized Payments)
# - item_total - the total value of all LineItems
# - adjustment_total - the total value of all adjustments
# - total - the "order total". This is equivalent to item_total plus adjustment_total
# - payment_total - total value of all finalized Payments (excludes non-finalized Payments)
# - item_total - total value of all LineItems
# - adjustment_total - total value of all adjustments
# - total - order total, it's the equivalent to item_total plus adjustment_total
def update_totals
order.payment_total = payments.completed.map(&:amount).sum
order.item_total = line_items.map(&:amount).sum
@@ -160,9 +160,9 @@ module OrderManagement
end
def infer_state(balance)
if balance > 0
if balance.positive?
'balance_due'
elsif balance < 0
elsif balance.negative?
'credit_owed'
elsif balance.zero?
'paid'

View File

@@ -58,7 +58,8 @@ module OrderManagement
end
it "is partial" do
allow(order).to receive_message_chain(:shipments, :states).and_return(["pending", "ready"])
allow(order).
to receive_message_chain(:shipments, :states).and_return(["pending", "ready"])
updater.update_shipment_state
expect(order.shipment_state).to eq 'partial'
end
@@ -260,7 +261,9 @@ module OrderManagement
context '#before_save_hook' do
let(:distributor) { build(:distributor_enterprise) }
let(:shipment) { create(:shipment_with, :shipping_method, shipping_method: shipping_method) }
let(:shipment) {
create(:shipment_with, :shipping_method, shipping_method: shipping_method)
}
before do
order.distributor = distributor