mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-09 23:06:06 +00:00
add condition on warning_forfeit_remaining_amount note
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
= link_to t("split_checkout.step2.voucher.remove_code"), voucher_adjustment_path(id: voucher_adjustment.id), method: "delete", data: { confirm: t("split_checkout.step2.voucher.confirm_delete") }
|
||||
|
||||
- # This might not be true, ie payment method including a fee which wouldn't be covered by voucher or tax implication raising total to be bigger than the voucher amount ?
|
||||
- if voucher_adjustment.originator.amount > order.pre_discount_total
|
||||
- if voucher_adjustment.originator.amount > order.pre_discount_total && voucher_adjustment.originator.is_a?(Vouchers::FlatRate)
|
||||
.checkout-input
|
||||
%span.formError.standalone
|
||||
= t("split_checkout.step2.voucher.warning_forfeit_remaining_amount")
|
||||
|
||||
52
spec/views/split_checkout/_voucher_section.html.haml_spec.rb
Normal file
52
spec/views/split_checkout/_voucher_section.html.haml_spec.rb
Normal file
@@ -0,0 +1,52 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "spec_helper"
|
||||
|
||||
describe "split_checkout/_voucher_section.html.haml" do
|
||||
let(:order) { create(:order_with_distributor, total: 10) }
|
||||
let(:flat_voucher) {
|
||||
create(:voucher_flat_rate, code: "flat_code",
|
||||
enterprise: order.distributor, amount: 20)
|
||||
}
|
||||
let(:percent_voucher) {
|
||||
create(:voucher_percentage_rate, code: 'percent_code',
|
||||
enterprise: order.distributor, amount: 20)
|
||||
}
|
||||
let(:note) {
|
||||
["Note: if your order total is less than your voucher",
|
||||
"you may not be able to spend the remaining value."].join(" ")
|
||||
}
|
||||
|
||||
it "should display warning_forfeit_remaining_amount note" do
|
||||
add_voucher(flat_voucher, order)
|
||||
|
||||
allow(view).to receive_messages(
|
||||
order:,
|
||||
voucher_adjustment: order.voucher_adjustments.first
|
||||
)
|
||||
assign(:order, order)
|
||||
|
||||
render
|
||||
expect(rendered).to have_content(note)
|
||||
end
|
||||
|
||||
it "should not display warning_forfeit_remaining_amount note" do
|
||||
add_voucher(percent_voucher, order)
|
||||
|
||||
allow(view).to receive_messages(
|
||||
order:,
|
||||
voucher_adjustment: order.voucher_adjustments.first
|
||||
)
|
||||
assign(:order, order)
|
||||
|
||||
render
|
||||
expect(rendered).to_not have_content(note)
|
||||
end
|
||||
|
||||
def add_voucher(voucher, order)
|
||||
voucher.create_adjustment(voucher.code, order)
|
||||
order.update_order!
|
||||
|
||||
VoucherAdjustmentsService.new(order).update
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user