Use old_outstanding_balance on disabled toggle

No need to go through the `OrderBalance` in this context since we
already check for the toggle.
This commit is contained in:
Pau Perez
2021-03-16 13:32:41 +01:00
parent 5082b6dc99
commit 9762275555
4 changed files with 5 additions and 5 deletions

View File

@@ -11,7 +11,7 @@ module Api
if OpenFoodNetwork::FeatureToggle.enabled?(:customer_balance, object.user)
-object.balance_value
else
object.outstanding_balance
object.old_outstanding_balance
end
end

View File

@@ -171,7 +171,7 @@ module OrderManagement
if OpenFoodNetwork::FeatureToggle.enabled?(:customer_balance, @user)
unique_orders(line_items).sum(&:new_outstanding_balance)
else
unique_orders(line_items).sum(&:outstanding_balance)
unique_orders(line_items).sum(&:old_outstanding_balance)
end
end

View File

@@ -195,7 +195,7 @@ describe OrderManagement::Reports::BulkCoop::BulkCoopReport do
end
it 'calls #outstanding_balance' do
expect_any_instance_of(Spree::Order).to receive(:outstanding_balance)
expect_any_instance_of(Spree::Order).to receive(:old_outstanding_balance)
subject.send(:customer_payments_amount_owed, [line_item])
end
end

View File

@@ -44,12 +44,12 @@ describe Api::OrderSerializer do
end
end
context 'when the customer_balance is not enabled' do
context 'when the customer_balance is disabled' do
before do
allow(OpenFoodNetwork::FeatureToggle)
.to receive(:enabled?).with(:customer_balance, order.user) { false }
allow(order).to receive(:outstanding_balance).and_return(123.0)
allow(order).to receive(:old_outstanding_balance).and_return(123.0)
end
it 'calls #outstanding_balance on the object' do