mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Fix easy rubocop issues
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user