Fix rubocop warning

This commit is contained in:
Gaetan Craig-Riou
2023-07-31 15:19:04 +10:00
parent 2857930263
commit 85adb9f345
2 changed files with 8 additions and 6 deletions

View File

@@ -47,9 +47,7 @@ class VoucherAdjustmentsController < BaseController
return false
end
# Clear payments and payment_fee, to not affect voucher adjustment calculation
@order.all_adjustments.payment_fee.destroy_all
@order.payments.clear
clear_payments
VoucherAdjustmentsService.new(@order).update
@order.update_totals_and_states
@@ -81,4 +79,10 @@ class VoucherAdjustmentsController < BaseController
def voucher_params
params.require(:order).permit(:voucher_code)
end
# Clear payments and payment fees, to not affect voucher adjustment calculation
def clear_payments
@order.all_adjustments.payment_fee.destroy_all
@order.payments.clear
end
end

View File

@@ -67,9 +67,7 @@ describe VoucherAdjustmentsController, type: :request do
context "when the order has a payment and payment feed" do
let(:payment_method) { create(:payment_method, calculator: calculator) }
let(:calculator) do
::Calculator::FlatPercentItemTotal.new(preferred_flat_percent: 10)
end
let(:calculator) { Calculator::FlatPercentItemTotal.new(preferred_flat_percent: 10) }
before do
create(:payment, order: order, payment_method: payment_method, amount: order.total)