From bad32e226e9355ac28fdb9f850f620e9daf6653d Mon Sep 17 00:00:00 2001 From: kernal053 Date: Tue, 10 Dec 2024 20:31:14 +0530 Subject: [PATCH] Fix label for other adjustments and add spec correspodingly --- .../order_mailer/_order_summary.html.haml | 2 ++ spec/mailers/order_mailer_spec.rb | 26 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/app/views/spree/order_mailer/_order_summary.html.haml b/app/views/spree/order_mailer/_order_summary.html.haml index aa1307dd0a..bf9b34c97d 100644 --- a/app/views/spree/order_mailer/_order_summary.html.haml +++ b/app/views/spree/order_mailer/_order_summary.html.haml @@ -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 diff --git a/spec/mailers/order_mailer_spec.rb b/spec/mailers/order_mailer_spec.rb index 34206213d5..a991f8659d 100644 --- a/spec/mailers/order_mailer_spec.rb +++ b/spec/mailers/order_mailer_spec.rb @@ -257,4 +257,30 @@ RSpec.describe Spree::OrderMailer do 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