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
Remove broken remove_transition that skips confirm step (#13901)
Kenta Ishizakia57e7576fe8a
diff --git a/spree/core/app/models/spree/order.rb b/spree/core/app/models/spree/order.rbindex c2de6ee71a..7727eb40c5 100644--- a/spree/core/app/models/spree/order.rb+++ b/spree/core/app/models/spree/order.rb@@ -102,7 +102,6 @@ module Spreego_to_state :payment, if: ->(order) { order.payment? || order.payment_required? }go_to_state :confirm, if: ->(order) { order.confirmation_required? }go_to_state :complete- remove_transition from: :delivery, to: :confirm, unless: ->(order) { order.confirmation_required? }endself.whitelisted_ransackable_associations = %w[shipments user created_by approver canceler promotions bill_address ship_address line_items store]diff --git a/spree/core/spec/models/spree/order/checkout_spec.rb b/spree/core/spec/models/spree/order/checkout_spec.rbindex 6a006cec56..8f548b5cde 100644--- a/spree/core/spec/models/spree/order/checkout_spec.rb+++ b/spree/core/spec/models/spree/order/checkout_spec.rb@@ -18,6 +18,7 @@ describe Spree::Order, type: :model do[{ address: :delivery },{ delivery: :payment },+ { delivery: :confirm },{ payment: :confirm },{ confirm: :complete },{ payment: :complete },@@ -32,9 +33,13 @@ describe Spree::Order, type: :model doendend- it 'does not have a transition from delivery to confirm' do+ # Regression test for #11900 — the delivery → confirm transition must+ # exist so that orders skipping payment (e.g. $0 orders) still reach the+ # confirm step when confirmation_required? is true. The transition is+ # gated at runtime by the :if option on the :confirm go_to_state.+ it 'has a transition from delivery to confirm' dotransition = Spree::Order.find_transition(from: :delivery, to: :confirm)- expect(transition).to be_nil+ expect(transition).not_to be_nilendit '.find_transition when contract was broken' do@@ -319,6 +324,22 @@ describe Spree::Order, type: :model doendend+ # Regression test for #11900 — a $0 order (payment not required) that+ # still requires confirmation must transition delivery → confirm, not+ # delivery → complete.+ context 'without payment required but with confirmation required' do+ before do+ allow(order).to receive_messages payment_required?: false+ allow(order).to receive_messages confirmation_required?: true+ end++ it 'transitions to confirm' do+ order.next!+ assert_state_changed(order, 'delivery', 'confirm')+ expect(order.state).to eq('confirm')+ end+ end+context 'correctly determining payment required based on shipping information' dolet(:shipment) doFactoryBot.create(:shipment)@@ -652,11 +673,6 @@ describe Spree::Order, type: :model doSpree::Order.checkout_flow(&@old_checkout_flow)end- it 'maintains removed transitions' do- transition = Spree::Order.find_transition(from: :delivery, to: :confirm)- expect(transition).to be_nil- end-context 'before' dobefore doSpree::Order.class_eval do@@ -704,11 +720,6 @@ describe Spree::Order, type: :model doSpree::Order.checkout_flow(&@old_checkout_flow)end- it 'maintains removed transitions' do- transition = Spree::Order.find_transition(from: :delivery, to: :confirm)- expect(transition).to be_nil- end-specify doorder = Spree::Order.newexpect(order.checkout_steps).to eq(%w(delivery complete))