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
Unify `rebuild_fulfillments!` naming and usage
Damian Legawiec6299cef25ac9
diff --git a/docs/developer/upgrades/5.6-to-6.0.mdx b/docs/developer/upgrades/5.6-to-6.0.mdxindex dd724a50b2..85168f5806 100644--- a/docs/developer/upgrades/5.6-to-6.0.mdx+++ b/docs/developer/upgrades/5.6-to-6.0.mdx@@ -226,6 +226,7 @@ Every rename keeps the legacy name working for one release with a deprecation wa| `use_billing` / `clone_billing_address` | `use_shipping` (shipping address is canonical) || `Fulfillment#ship`, `#ship!`, `#shipped?`, `#can_ship?`, `#shipping_method`, `#add_shipping_method` | `#fulfill`, `#fulfill!`, `#fulfilled?`, `#can_fulfill?`, `#delivery_method`, `#add_delivery_method` || `LineItem#target_shipment` | `#target_fulfillment` |+| `create_proposed_shipments` / `create_proposed_fulfillments` | `#rebuild_fulfillments!` (both models) || `Order#remove_out_of_stock_items!` | cart-side only (`Spree::Carts::RemoveOutOfStockItems`) || `Cart#number` (Store API field) | `id` — carts have no order-style number; the field mirrors the prefixed ID for one release || `order.completed` event | `order.placed` |diff --git a/spree/core/app/models/spree/cart.rb b/spree/core/app/models/spree/cart.rbindex 317353f152..41ae3e86cb 100644--- a/spree/core/app/models/spree/cart.rb+++ b/spree/core/app/models/spree/cart.rb@@ -218,12 +218,6 @@ module Spreeendalias set_shipments_cost set_fulfillments_cost- # @deprecated Use {#rebuild_fulfillments!}; removed in 6.1.- def create_proposed_fulfillments- Spree::Deprecation.warn('Spree::Cart#create_proposed_fulfillments is deprecated and will be removed in Spree 6.1. Use #rebuild_fulfillments! instead.')- rebuild_fulfillments!- end-def ensure_updated_fulfillmentsrebuild_fulfillments! unless completed?end@@ -238,7 +232,6 @@ module Spreerecalculate_totals!end-# Binds a signing-in user to the cart through the swappable associate# service (same seam Order#associate_user! uses).def associate_user!(user, override_email = true)diff --git a/spree/core/app/services/spree/orders/build_fulfillments.rb b/spree/core/app/services/spree/orders/build_fulfillments.rbindex 48bb7d9706..b3e0f67939 100644--- a/spree/core/app/services/spree/orders/build_fulfillments.rb+++ b/spree/core/app/services/spree/orders/build_fulfillments.rb@@ -17,7 +17,7 @@ module Spreereturn success(order) unless order.line_items.any?return success(order) unless order.delivery_required?- order.create_proposed_fulfillments+ order.rebuild_fulfillments!order.create_shipment_tax_charge!order.set_fulfillments_costorder.apply_free_shipping_promotionsdiff --git a/spree/core/spec/models/spree/cart_spec.rb b/spree/core/spec/models/spree/cart_spec.rbindex 668c2db33c..556f4118a0 100644--- a/spree/core/spec/models/spree/cart_spec.rb+++ b/spree/core/spec/models/spree/cart_spec.rb@@ -237,6 +237,17 @@ describe Spree::Cart, type: :model doendend+ describe '#create_proposed_fulfillments (deprecated)' do+ it 'delegates to #rebuild_fulfillments! with a deprecation warning' do+ cart = build(:cart, store: store)++ expect(Spree::Deprecation).to receive(:warn).with(/create_proposed_fulfillments/)+ expect(cart).to receive(:rebuild_fulfillments!)++ cart.create_proposed_fulfillments+ end+ end+describe '#coupon_code=' doit 'normalizes to a stripped, lowercased code' doexpect(build(:cart, coupon_code: ' SAVE10 ').read_attribute(:coupon_code)).to eq('save10')diff --git a/spree/core/spec/models/spree/order_spec.rb b/spree/core/spec/models/spree/order_spec.rbindex 5226faf80d..323c6c814f 100644--- a/spree/core/spec/models/spree/order_spec.rb+++ b/spree/core/spec/models/spree/order_spec.rb@@ -1823,14 +1823,23 @@ describe Spree::Order, type: :model doendend- describe '#rebuild_fulfillments!' do- it 'delegates to #create_proposed_fulfillments with a deprecation warning' do+ describe 'legacy proposal-rebuild bridges' do+ it 'delegates #create_proposed_fulfillments to #rebuild_fulfillments! with a deprecation warning' doorder = create(:order)expect(Spree::Deprecation).to receive(:warn).with(/create_proposed_fulfillments/)- expect(order).to receive(:create_proposed_fulfillments)+ expect(order).to receive(:rebuild_fulfillments!)++ order.create_proposed_fulfillments+ end++ it 'delegates #create_proposed_shipments to #rebuild_fulfillments! with a deprecation warning' do+ order = create(:order)++ expect(Spree::Deprecation).to receive(:warn).with(/create_proposed_shipments/)+ expect(order).to receive(:rebuild_fulfillments!)- order.rebuild_fulfillments!+ order.create_proposed_shipmentsendend