Skip to content

Commit

Permalink
Merge pull request openfoodfoundation#13061 from kernal053/add-vouche…
Browse files Browse the repository at this point in the history
…r-label-to-edit-cart-page

Add 'Voucher:' before voucher code on edit cart page
  • Loading branch information
filipefurtad0 authored Jan 17, 2025
2 parents 3c1dd10 + 45a4b33 commit ace3bfa
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/views/spree/orders/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@
- checkout_adjustments_for(@order, exclude: [:line_item]).reverse_each do |adjustment|
%tr.order-adjustment
%td.text-right{:colspan => "3"}
= adjustment.label
- if adjustment.originator_type == "Voucher"
= "#{t(:voucher)}:"
= adjustment.label
- else
= adjustment.label
%td.text-right.total
%span= adjustment.display_amount.to_html
%td
Expand Down
26 changes: 26 additions & 0 deletions spec/views/spree/orders/edit.html.haml_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,30 @@
expect(rendered).to have_selector(".unit-price")
end
end

describe "display adjustments" do
let(:voucher) { create(:voucher, enterprise: order.distributor) }

before do
voucher.create_adjustment(voucher.code, order)
OrderManagement::Order::Updater.new(order).update_voucher
render
end

it "includes Voucher text with label" do
expect(rendered).to have_content("Voucher:\n#{voucher.code}")
end

# Shipping fee is derived from 'completed_order_with_fees' factory.
# It applies when using shipping method such as Home Delivery.
it "includes Shipping label" do
expect(rendered).to have_content("Shipping")
end

# Transaction fee is derived from 'completed_order_with_fees' factory.
# It applies when using payment methods such as Check & Stripe.
it "includes Transaction fee label" do
expect(rendered).to have_content("Transaction fee")
end
end
end

0 comments on commit ace3bfa

Please sign in to comment.