Skip to content

armgit / spree

Public Imported from GitHub
0

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.

Fixed flaky email tests (#12961)

Damian Legawiec5bcb40f43d1d
diff --git a/emails/spec/mailers/spree/order_mailer_spec.rb b/emails/spec/mailers/spree/order_mailer_spec.rb
index c911fd119a..bd1d8599ff 100644
--- a/emails/spec/mailers/spree/order_mailer_spec.rb
+++ b/emails/spec/mailers/spree/order_mailer_spec.rb
@@ -5,7 +5,7 @@ describe Spree::OrderMailer, type: :mailer do
include EmailSpec::Helpers
include EmailSpec::Matchers
- let!(:store) { create(:store, name: 'First Store', default: true, default_locale: 'en') }
+ let!(:store) { @default_store }
let(:second_store) { create(:store, name: 'Second Store', url: 'other.example.com', default_locale: 'en') }
let(:order) do
@@ -87,7 +87,7 @@ describe Spree::OrderMailer, type: :mailer do
end
it 'has correct subject line' do
- expect(notification_email.subject).to eq('First Store received a new order')
+ expect(notification_email.subject).to eq("#{store.name} received a new order")
end
it 'shows the correct heading in email body' do
@@ -272,6 +272,7 @@ describe Spree::OrderMailer, type: :mailer do
end
context 'with custom domain' do
+ let(:store) { create(:store) }
let!(:custom_domain) { create(:custom_domain, store: store, url: 'my-store.com') }
it 'uses custom domain for URLs in emails' do
diff --git a/emails/spec/mailers/spree/shipment_mailer_spec.rb b/emails/spec/mailers/spree/shipment_mailer_spec.rb
index 509cc490cd..4eae061a44 100644
--- a/emails/spec/mailers/spree/shipment_mailer_spec.rb
+++ b/emails/spec/mailers/spree/shipment_mailer_spec.rb
@@ -5,7 +5,7 @@ describe Spree::ShipmentMailer, type: :mailer do
include EmailSpec::Helpers
include EmailSpec::Matchers
- let(:store) { create(:store, default: true) }
+ let(:store) { @default_store }
let(:order) { create(:shipped_order, store: store, email: '[email protected]', user: nil) }
let(:shipment) { order.shipments.first }
let(:shipping_method) { shipment.shipping_method }