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
Clean up everything the concurrency example commits
Damian Legawiec171ee7b1e755
diff --git a/spree/core/spec/models/spree/stock_level_spec.rb b/spree/core/spec/models/spree/stock_level_spec.rbindex 433eccb15f..52d2f6cbed 100644--- a/spree/core/spec/models/spree/stock_level_spec.rb+++ b/spree/core/spec/models/spree/stock_level_spec.rb@@ -488,6 +488,22 @@ describe Spree::StockLevel, type: :model docontext 'released concurrently', if: ENV['DB'] == 'postgres' doself.use_transactional_tests = false+ # Everything this context creates is COMMITTED, so whatever the after+ # hook misses stays in the worker database for every later example in+ # the run. The factory chain quietly commits side rows (a tax+ # category, a delivery profile), and a leftover tax category is+ # poison: the product factory takes TaxCategory.first, so every later+ # tax example binds its rate to one category and its product to the+ # other — included_tax_total 0, in whatever file happens to run next.+ # Snapshot the side tables and delete exactly what this example added.+ before do+ @preexisting = {+ Spree::TaxCategory => Spree::TaxCategory.ids,+ Spree::DeliveryProfile => Spree::DeliveryProfile.ids,+ Spree::OptionType => Spree::OptionType.ids+ }+ end+let!(:concurrent_level) { create(:stock_level, adjust_count_on_hand: false) }after do@@ -496,6 +512,7 @@ describe Spree::StockLevel, type: :model doSpree::StockMovement.where(stock_level_id: concurrent_level.id).delete_alllocation.really_destroy!product.really_destroy!+ @preexisting.each { |model, ids| model.where.not(id: ids).delete_all }endit 'never withdraws more promise than the level holds' do