mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Fix spec when adding a product with transaction fee
Previous iteration did not actually check the payment fee had been updated. It also checks the order total get correctly updated. Spec is passing, so fixing the order updater also fix this bug : https://github.com/openfoodfoundation/openfoodnetwork/issues/12512
This commit is contained in:
@@ -179,20 +179,22 @@ RSpec.describe '
|
||||
context "When adding a product on an order with transaction fee" do
|
||||
let(:order_with_fees) { create(:completed_order_with_fees, user:, distributor:, order_cycle: ) }
|
||||
|
||||
it 'recalculates transaction fee' do
|
||||
pending
|
||||
it "recalculates transaction fee and order total" do
|
||||
login_as_admin
|
||||
visit spree.edit_admin_order_path(order_with_fees)
|
||||
|
||||
adjustment_for_transaction_fee = order_with_fees.all_adjustments.payment_fee.eligible.first
|
||||
transaction_fee = adjustment_for_transaction_fee.amount
|
||||
# Fee is $5 per item and we have two line items
|
||||
expect(page).to have_css("#order_adjustments", text: 10.00)
|
||||
expect(page).to have_css(".order-total", text: 36.00)
|
||||
|
||||
expect(page.find("#order_adjustments").text).to have_content(transaction_fee)
|
||||
expect {
|
||||
select2_select product.name, from: 'add_variant_id', search: true
|
||||
find('button.add_variant').click
|
||||
}.to change { order_with_fees.payments.first.adjustment.amount }.from(10.00).to(15.00)
|
||||
.and change { order_with_fees.reload.total }.from(36.00).to(63.99)
|
||||
|
||||
select2_select product.name, from: 'add_variant_id', search: true
|
||||
find('button.add_variant').click
|
||||
expect(page).to have_css("#order_adjustments",
|
||||
text: adjustment_for_transaction_fee.reload.amount)
|
||||
expect(page).to have_css("#order_adjustments", text: 15.00)
|
||||
expect(page).to have_css(".order-total", text: 63.99)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user