Skip to content

Commit

Permalink
Add 'Voucher:' before voucher code on edit cart page. Add spec corres…
Browse files Browse the repository at this point in the history
…pondigly
  • Loading branch information
kernal053 committed Jan 4, 2025
1 parent 35fa415 commit 98adefb
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
5 changes: 4 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,10 @@
- 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(:order_voucher_label, code: adjustment.label)
- else
= adjustment.label
%td.text-right.total
%span= adjustment.display_amount.to_html
%td
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2455,6 +2455,7 @@ en:
order_back_to_store: Back To Store
order_back_to_cart: Back To Cart
order_back_to_website: Back To Website
order_voucher_label: "Voucher: %{code}"
checkout_details_title: Checkout Details
checkout_payment_title: Checkout Payment
checkout_summary_title: Checkout Summary
Expand Down
24 changes: 24 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,28 @@
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 include("Voucher: #{voucher.code}")
end

# shipping fee is derived from 'completed_order_with_fees' factory, it applies when using shipping method such as Home Delivery.

Check warning on line 48 in spec/views/spree/orders/edit.html.haml_spec.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Line is too long. [132/100] Raw Output: spec/views/spree/orders/edit.html.haml_spec.rb:48:101: C: Layout/LineLength: Line is too long. [132/100]
it "includes Shipping label" do
expect(rendered).to include("Shipping")
end

# transaction fee is derived from 'completed_order_with_fees' factory, it applies when using payment methods such as Check & Stripe.

Check warning on line 53 in spec/views/spree/orders/edit.html.haml_spec.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Line is too long. [136/100] Raw Output: spec/views/spree/orders/edit.html.haml_spec.rb:53:101: C: Layout/LineLength: Line is too long. [136/100]
it "includes Transaction fee label" do
expect(rendered).to include("Transaction fee")
end
end
end

0 comments on commit 98adefb

Please sign in to comment.