Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Skip sending a reimbursement email if send_consumer_transactional_emails is set to false (#12912)
Łukasz Adamczyk3aab58bbd28c
diff --git a/emails/app/models/spree/reimbursement/emails.rb b/emails/app/models/spree/reimbursement/emails.rbindex 1cfe575820..404b599f85 100644--- a/emails/app/models/spree/reimbursement/emails.rb+++ b/emails/app/models/spree/reimbursement/emails.rb@@ -2,7 +2,7 @@ module Spreeclass Reimbursement < Spree.base_classmodule Emailsdef send_reimbursement_email- Spree::ReimbursementMailer.reimbursement_email(id).deliver_later+ Spree::ReimbursementMailer.reimbursement_email(id).deliver_later if store.prefers_send_consumer_transactional_emails?endendenddiff --git a/emails/spec/models/spree/reimbursement_spec.rb b/emails/spec/models/spree/reimbursement_spec.rbindex 1d4048551a..acf0e150b1 100644--- a/emails/spec/models/spree/reimbursement_spec.rb+++ b/emails/spec/models/spree/reimbursement_spec.rb@@ -34,5 +34,20 @@ describe Spree::Reimbursement, type: :model doexpect(Spree::ReimbursementMailer).to receive(:reimbursement_email).with(reimbursement.id) { double(deliver_later: true) }subjectend++ context 'when send_consumer_transactional_emails store setting is set to false' do+ before do+ store.update!(preferred_send_consumer_transactional_emails: false)+ end++ after do+ store.update!(preferred_send_consumer_transactional_emails: true)+ end++ it 'does not trigger the reimbursement mailer to be sent' do+ expect(Spree::ReimbursementMailer).not_to receive(:reimbursement_email)+ subject+ end+ endendend