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.

Fix missing store.

Matthew Kennedyb7588678ff46
diff --git a/core/lib/spree/testing_support/order_walkthrough.rb b/core/lib/spree/testing_support/order_walkthrough.rb
index 18caeb4f09..7eb799f198 100644
--- a/core/lib/spree/testing_support/order_walkthrough.rb
+++ b/core/lib/spree/testing_support/order_walkthrough.rb
@@ -1,7 +1,13 @@
class OrderWalkthrough
def self.up_to(state)
- # A default store must exist to provide store settings
- store = Spree::Store.default || FactoryBot.create(:store, default: true)
+
+ # If one or more stores exist, set the local variable to the default Store
+ # else creat a new default store from scratch.
+ if Spree::Store.exists?
+ store = Spree::Store.default || FactoryBot.create(:store, default: true)
+ else
+ store = FactoryBot.create(:store, default: true)
+ end
# A payment method must exist for an order to proceed through the Address state
unless Spree::PaymentMethod.exists?