Skip to content

Commit

Permalink
Fix label for other adjustments and add spec correspodingly
Browse files Browse the repository at this point in the history
  • Loading branch information
kernal053 authored and drummer83 committed Jan 2, 2025
1 parent 65f7980 commit bad32e2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/views/spree/order_mailer/_order_summary.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
%td{align: "right", colspan: "3"}
- if adjustment.originator_type == "Voucher"
= t(:email_order_summary_voucher_label, code: adjustment.label)
- else
= "#{adjustment.label}:"
%td{align: "right"}
= adjustment.display_amount
%tr
Expand Down
26 changes: 26 additions & 0 deletions spec/mailers/order_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,30 @@
end
end
end

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

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

let!(:confirmation_email_for_customer) { Spree::OrderMailer.confirm_email_for_customer(order) }
let!(:confirmation_email_for_shop) { Spree::OrderMailer.confirm_email_for_shop(order) }
let!(:cancellation_email) { Spree::OrderMailer.cancel_email(order) }

it "includes Voucher text with label" do
expect(confirmation_email_for_customer.body).to include("Voucher (#{voucher.code}):")
expect(confirmation_email_for_shop.body).to include("Voucher (#{voucher.code}):")
expect(cancellation_email.body).to include("Voucher (#{voucher.code}):")
end

it "includes Shipping label" do
expect(confirmation_email_for_customer.body).to include("Shipping:")
expect(confirmation_email_for_shop.body).to include("Shipping:")
expect(cancellation_email.body).to include("Shipping:")
end
end
end

0 comments on commit bad32e2

Please sign in to comment.