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
Fix stock_item around_create callback making others fail.
Sebastian Palmab93d34501838
diff --git a/api/app/models/spree/api/webhooks/stock_item_decorator.rb b/api/app/models/spree/api/webhooks/stock_item_decorator.rbindex 6c5d630515..4de8c59bec 100644--- a/api/app/models/spree/api/webhooks/stock_item_decorator.rb+++ b/api/app/models/spree/api/webhooks/stock_item_decorator.rb@@ -12,6 +12,7 @@ module Spreedef queue_webhooks_requests_for_variant_backorderable_on_create!was_out_of_stock = variant.out_of_stock?yield+ reloadreturn unless emits_webhook_event_on_create?(variant.reload, was_out_of_stock)variant.queue_webhooks_requests!('variant.backorderable')@@ -27,8 +28,7 @@ module Spreewas_out_of_stock = variant.out_of_stock?was_not_orderable = !variant.backorderable?yield- variant.reload- variant.touch # changes must be reflected before instantiating the serializer+ touch # changes must be reflected before instantiating the serializerreturn unless emits_webhook_event_on_update?(variant, was_out_of_stock, was_not_orderable)variant.queue_webhooks_requests!('variant.backorderable')diff --git a/api/spec/models/concerns/spree/webhooks/has_webhooks_spec.rb b/api/spec/models/concerns/spree/webhooks/has_webhooks_spec.rbindex a22a76fa69..bf9772be55 100644--- a/api/spec/models/concerns/spree/webhooks/has_webhooks_spec.rb+++ b/api/spec/models/concerns/spree/webhooks/has_webhooks_spec.rb@@ -31,13 +31,13 @@ describe Spree::Webhooks::HasWebhooks docontext 'after_destroy_commit' dobefore { product.destroy }- it_behaves_like 'not queueing an event request', 'product.create'+ it_behaves_like 'not queueing an event request', 'product.destroy'endcontext 'after_update_commit' dobefore { product.update(name: 'updated') }- it_behaves_like 'not queueing an event request', 'product.create'+ it_behaves_like 'not queueing an event request', 'product.update'endenddiff --git a/api/spec/models/spree/api/webhooks/stock_item_decorator_spec.rb b/api/spec/models/spree/api/webhooks/stock_item_decorator_spec.rbindex 898e5c20a9..dc99286513 100644--- a/api/spec/models/spree/api/webhooks/stock_item_decorator_spec.rb+++ b/api/spec/models/spree/api/webhooks/stock_item_decorator_spec.rb@@ -2,7 +2,7 @@ require 'spec_helper'describe Spree::Api::Webhooks::StockItemDecorator dodescribe 'emitting variant.backorderable' do- let(:body) { Spree::Api::V2::Platform::VariantSerializer.new(variant).serializable_hash.to_json }+ let(:body) { Spree::Api::V2::Platform::VariantSerializer.new(variant.reload).serializable_hash.to_json }let(:variant) { create(:variant) }before do