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: Cart not answering legacy Order names (#14771)
Damian Legawiec2adb56860a69
diff --git a/docs/developer/upgrades/5.6-to-6.0.mdx b/docs/developer/upgrades/5.6-to-6.0.mdxindex fbb7169855..7fcbe92b21 100644--- a/docs/developer/upgrades/5.6-to-6.0.mdx+++ b/docs/developer/upgrades/5.6-to-6.0.mdx@@ -714,13 +714,15 @@ If you subclassed `Spree::Report` in your own application, that class no longerEvery rename keeps the legacy name working for one release with a deprecation warning. The notable ones:+Before 6.0 a cart was an incomplete order, so extensions written for 5.x (payment gateways in particular) call these names on carts. The rows marked *Order and Cart* are answered by `Spree::Cart` as well as `Spree::Order`, with the same warning.+| Deprecated | Use instead ||---|---|| `Order#finalize!` | `Spree.order_complete_workflow` || `Order#updater`, `Spree::OrderUpdater`, `Spree::CartUpdater` | `#recalculate_totals!` / `#update_statuses!` |-| `Order#shipping_discount` | `#fulfillment_discount` |-| `Order#special_instructions` | `#customer_note` (column renamed) |-| `Order#promo_total`, `#item_count`, `#ship_total` | `#discount_total`, `#total_quantity`, `#delivery_total` (columns renamed) |+| `Order#shipping_discount` (Order and Cart) | `#fulfillment_discount` |+| `Order#special_instructions` (Order and Cart) | `#customer_note` (column renamed) |+| `Order#promo_total`, `#item_count`, `#ship_total`, `#shipment_total` (Order and Cart) | `#discount_total`, `#total_quantity`, `#delivery_total` (columns renamed) || `LineItem#promo_total`, `Fulfillment#promo_total` | `#discount_total` (columns renamed) || `Address#firstname`, `#lastname`, `#zipcode` | `#first_name`, `#last_name`, `#postal_code` (columns renamed) || `Address.normalize_zipcode`, `#normalized_zipcode` | `.normalize_postal_code`, `#normalized_postal_code` |@@ -734,10 +736,15 @@ Every rename keeps the legacy name working for one release with a deprecation wa| `Fulfillment#ship`, `#ship!` | `Spree.fulfillment_fulfill_workflow.call(fulfillment:)` (`Spree::Fulfillments::Fulfill`) || `Fulfillment#shipped?`, `#can_ship?`, `#shipping_method`, `#add_shipping_method` | `#fulfilled?`, `#can_fulfill?`, `#delivery_method`, `#add_delivery_method` || `LineItem#target_shipment` | `#target_fulfillment` |-| `Order#create_proposed_shipments` / `#create_proposed_fulfillments` | `#rebuild_fulfillments!` (Cart ships with the new name only) |+| `Order#create_proposed_shipments` / `#create_proposed_fulfillments` (Order and Cart) | `#rebuild_fulfillments!` |+| `#user`, `#user=`, `#user_id`, `#associate_user!` (Order and Cart) | `#customer`, `#customer=`, `#customer_id`, `#associate_customer!` |+| `#shipments`, `#set_shipments_cost`, `#ensure_updated_shipments`, `#display_shipment_total` (Order and Cart) | `#fulfillments`, `#set_fulfillments_cost`, `#ensure_updated_fulfillments`, `#display_delivery_total` |+| `#update_with_updater!` (Order and Cart) | `#recalculate_totals!` |+| `#available_payment_methods`, `#collect_payment_methods`, `#collect_frontend_payment_methods` (Order and Cart) | `#payment_methods` |+| `#all_line_items` (Order and Cart) | `#line_items` || `Order#remove_out_of_stock_items!` | cart-side only (`Spree::Carts::RemoveOutOfStockItems`) |-| `Order#delivery_required?` | `#delivery_step_required?` — digital and pickup are deliveries too; this asks whether the customer must choose a delivery option |-| `Order#requires_ship_address?` | `#shipping_address_required?` — decided by the selected delivery methods (`DeliveryMethod#requires_address?`); digital, pickup, and pickup-point deliveries need no customer address |+| `Order#delivery_required?` (Order and Cart) | `#delivery_step_required?` — digital and pickup are deliveries too; this asks whether the customer must choose a delivery option |+| `Order#requires_ship_address?` (Order and Cart) | `#shipping_address_required?` — decided by the selected delivery methods (`DeliveryMethod#requires_address?`); digital, pickup, and pickup-point deliveries need no customer address || `requirements[].field` / `.code` `shipping_method` (Store API) | `delivery_method` / `delivery_method_required` — no bridge; clients keying off the delivery requirement must switch both tokens || `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/api/app/controllers/spree/api/v3/store/carts_controller.rb b/spree/api/app/controllers/spree/api/v3/store/carts_controller.rbindex d8575e5de8..30f9d3242e 100644--- a/spree/api/app/controllers/spree/api/v3/store/carts_controller.rb+++ b/spree/api/app/controllers/spree/api/v3/store/carts_controller.rb@@ -41,7 +41,7 @@ module Spreedef createresult = Spree::Carts::Create.call(params: permitted_params.merge(- user: current_user,+ customer: current_user,store: current_store,channel: current_channel,currency: current_currency,diff --git a/spree/core/app/models/concerns/spree/purchase/deprecated_aliases.rb b/spree/core/app/models/concerns/spree/purchase/deprecated_aliases.rbnew file mode 100644index 0000000000..e570d10c2d--- /dev/null+++ b/spree/core/app/models/concerns/spree/purchase/deprecated_aliases.rb@@ -0,0 +1,87 @@+module Spree+ module Purchase+ # One-release bridges for the names renamed in 6.0, shared by+ # {Spree::Cart} and {Spree::Order}. Before 6.0 a cart was an incomplete+ # order, so extensions written against 5.x (payment gateways, checkout+ # plugins) call the legacy names on carts too. Every legacy name warns and+ # forwards to its replacement. Removed in 6.1.+ #+ # Renamed columns are also registered with +alias_attribute+, so the legacy+ # name keeps working in +where+ / +find_by+ (those paths do not warn).+ module DeprecatedAliases+ extend ActiveSupport::Concern++ RENAMED_ATTRIBUTES = {+ promo_total: :discount_total,+ item_count: :total_quantity,+ shipment_total: :delivery_total,+ ship_total: :delivery_total,+ special_instructions: :customer_note+ }.freeze++ RENAMED_METHODS = {+ display_promo_total: :display_discount_total,+ display_shipment_total: :display_delivery_total,+ display_ship_total: :display_delivery_total,+ shipping_discount: :fulfillment_discount,+ delivery_required?: :delivery_step_required?,+ requires_ship_address?: :shipping_address_required?,+ set_shipments_cost: :set_fulfillments_cost,+ ensure_updated_shipments: :ensure_updated_fulfillments,+ create_proposed_fulfillments: :rebuild_fulfillments!,+ create_proposed_shipments: :rebuild_fulfillments!,+ associate_user!: :associate_customer!,+ update_with_updater!: :recalculate_totals!,+ all_line_items: :line_items+ }.freeze++ # 5.x took a store argument; payment methods now always come from the+ # purchase's own store.+ RENAMED_PAYMENT_METHOD_READERS = %i[+ available_payment_methods+ collect_payment_methods+ collect_frontend_payment_methods+ ].freeze++ included do+ include Spree::DeprecatedCustomerAlias++ RENAMED_ATTRIBUTES.each do |legacy_name, current_name|+ alias_attribute legacy_name, current_name+ end+ end++ RENAMED_ATTRIBUTES.each do |legacy_name, current_name|+ define_method(legacy_name) do+ warn_deprecated_name(legacy_name, current_name)+ public_send(current_name)+ end++ define_method(:"#{legacy_name}=") do |value|+ warn_deprecated_name(:"#{legacy_name}=", :"#{current_name}=")+ public_send(:"#{current_name}=", value)+ end+ end++ RENAMED_METHODS.each do |legacy_name, current_name|+ define_method(legacy_name) do |*args, **options, &block|+ warn_deprecated_name(legacy_name, current_name)+ public_send(current_name, *args, **options, &block)+ end+ end++ RENAMED_PAYMENT_METHOD_READERS.each do |legacy_name|+ define_method(legacy_name) do |*|+ warn_deprecated_name(legacy_name, :payment_methods)+ payment_methods+ end+ end++ private++ def warn_deprecated_name(legacy_name, current_name)+ Spree::Deprecation.warn("#{self.class.name}##{legacy_name} is deprecated and will be removed in Spree 6.1. Use ##{current_name} instead.")+ end+ end+ end+enddiff --git a/spree/core/app/models/spree/cart.rb b/spree/core/app/models/spree/cart.rbindex ddb9649fa0..252ae72007 100644--- a/spree/core/app/models/spree/cart.rb+++ b/spree/core/app/models/spree/cart.rb@@ -36,6 +36,7 @@ module Spreeinclude Spree::Purchase::Validationsinclude Spree::Purchase::Totalsinclude Spree::Purchase::Lifecycle+ include Spree::Purchase::DeprecatedAliases# Concurrency is manual (the API's OrderLock semantics — compare# client-sent version, 409 on mismatch); Rails auto-locking must not@@ -54,16 +55,7 @@ module Spree:discount_total, :fee_total, :delivery_total, :total, :payment_total, :outstanding_balance,:tax_total, :pre_tax_item_amount, :pre_tax_total, :amount_due- alias display_promo_total display_discount_total- alias display_ship_total display_delivery_total- alias_attribute :ship_total, :delivery_total-belongs_to :customer, class_name: "::#{Spree.customer_class}", optional: true- # Order-parity aliases — shared Cart/Order code (services, Purchase- # concerns) reads #user; the cart column is customer_id.- alias_method :user, :customer- alias_method :user=, :customer=- alias_attribute :user_id, :customer_id# Codes are stored stripped + lowercased so lookups stay case-insensitive;# normalizes also applies to finder values.normalizes :coupon_code, with: ->(code) { code.to_s.strip.downcase.presence }@@ -87,6 +79,8 @@ module Spreeendendhas_many :fulfillment_items, through: :fulfillments, class_name: 'Spree::FulfillmentItem'+ # Legacy name (5.x carts were orders) — removed in 6.1+ has_many :shipments, -> { order(:created_at, :id) }, class_name: 'Spree::Fulfillment', inverse_of: :cart, deprecated: truehas_many :order_promotions, class_name: 'Spree::OrderPromotion', inverse_of: :cart, dependent: :destroyhas_many :promotions, through: :order_promotions, class_name: 'Spree::Promotion'has_many :payments, class_name: 'Spree::Payment', inverse_of: :cart, dependent: :destroy@@ -229,7 +223,6 @@ module Spreeupdated_at: Time.current)end- alias set_shipments_cost set_fulfillments_costdef ensure_updated_fulfillmentsrebuild_fulfillments! unless completed?diff --git a/spree/core/app/models/spree/order.rb b/spree/core/app/models/spree/order.rbindex 91611171ef..eece1f7dc3 100644--- a/spree/core/app/models/spree/order.rb+++ b/spree/core/app/models/spree/order.rb@@ -45,6 +45,7 @@ module Spreeinclude Spree::Purchase::Validationsinclude Spree::Purchase::Totalsinclude Spree::Purchase::Lifecycle+ include Spree::Purchase::DeprecatedAliaseshas_spree_number prefix: 'R'include Spree::NumberIdentifier@@ -69,8 +70,6 @@ module Spree:payment_total, :amount_due, :fee_total,:commission_amount_total, :commission_tax_total, :commission_total- alias display_ship_total display_delivery_total- alias_attribute :ship_total, :delivery_total# Transient warnings populated by remove_out_of_stock_items! and ensure_available_delivery_ratesattribute :warnings, default: -> { [] }@@ -140,24 +139,6 @@ module SpreeSpree::Checkout::Registry.step_names_for(self).reject { |step| step == 'complete' }end- # Standardized column names (renamed in 6.0); legacy readers stay as- # aliases one release.- alias_attribute :promo_total, :discount_total- alias display_promo_total display_discount_total- alias_attribute :item_count, :total_quantity-- # @deprecated The column is +customer_note+ since 6.0; removed in 6.1.- def special_instructions- Spree::Deprecation.warn('Spree::Order#special_instructions is deprecated and will be removed in Spree 6.1. Use #customer_note instead.')- customer_note- end-- # @deprecated See {#special_instructions}; removed in 6.1.- def special_instructions=(value)- Spree::Deprecation.warn('Spree::Order#special_instructions= is deprecated and will be removed in Spree 6.1. Use #customer_note= instead.')- self.customer_note = value- end-# lock_version (renamed from state_lock_version) drives the API's manual# optimistic concurrency (compare client-sent version, 409 on mismatch) —# Rails auto-locking must not raise on internal saves.@@ -209,14 +190,6 @@ module SpreeASSOCIATED_CUSTOMER_ATTRIBUTES = [:customer_id, :email, :bill_address_id, :ship_address_id]- # @deprecated Use {Spree::Purchase::PaymentProcessing#payment_methods};- # removed in 6.1.- def collect_frontend_payment_methods- Spree::Deprecation.warn('Spree::Order#collect_frontend_payment_methods is deprecated and will be removed in Spree 6.1. Use #payment_methods instead.')- payment_methods- end-- include Spree::DeprecatedCustomerAliasbelongs_to :customer, class_name: "::#{Spree.customer_class}", optional: true, autosave: true# The cart this order was completed from (unique — the completion@@ -296,8 +269,6 @@ module Spree# Legacy names — removed in 6.1 (real names: fulfillments, delivery_total,# fulfillment_status since 6.0)has_many :shipments, class_name: 'Spree::Fulfillment', inverse_of: :order, deprecated: true- alias_attribute :shipment_total, :delivery_total- alias display_shipment_total display_delivery_totalalias_attribute :shipment_state, :fulfillment_status# Deprecated alias — the column is payment_status since 6.0; remove in 6.1.alias_attribute :payment_state, :payment_status@@ -447,11 +418,6 @@ module Spreeend- # @deprecated Use {#fulfillment_discount}; removed in 6.1.- def shipping_discount- Spree::Deprecation.warn('Spree::Order#shipping_discount is deprecated and will be removed in Spree 6.1. Use #fulfillment_discount instead.')- fulfillment_discount- end@@ -651,12 +617,6 @@ module SpreeSpree.order_update_statuses_service.call(order: self)end- # @deprecated Use {#recalculate_totals!}; removed in 6.1.- def update_with_updater!- Spree::Deprecation.warn('Spree::Order#update_with_updater! is deprecated and will be removed in Spree 6.1. Use #recalculate_totals! instead.')- recalculate_totals!- end-# @deprecated Use {Spree::Carts::Merge}; removed in 6.1.def merger@merger ||= Spree::OrderMerger.new(self)@@ -684,12 +644,6 @@ module SpreeSpree.cart_associate_service.call(guest_cart: self, customer: customer, override_email: override_email)end- # @deprecated Use {#associate_customer!}; removed in 6.1.- def associate_user!(user, override_email = true)- Spree::Deprecation.warn('Spree::Order#associate_user! is deprecated and will be removed in Spree 6.1. Use #associate_customer! instead.')- associate_customer!(user, override_email)- end-def disassociate_customer!nullified_attributes = ASSOCIATED_CUSTOMER_ATTRIBUTES.index_with(nil)@@ -866,12 +820,6 @@ module Spree- def available_payment_methods(store = nil)- Spree::Deprecation.warn('`Order#available_payment_methods` is deprecated and will be removed in Spree 6.1. Use `payment_methods` instead.')-- @available_payment_methods ||= collect_payment_methods(store)- end-def insufficient_stock_linesline_items.select(&:insufficient_stock?)end@@ -960,30 +908,6 @@ module Spreeendend- # @deprecated Use {#rebuild_fulfillments!}; removed in 6.1.- def create_proposed_fulfillments- Spree::Deprecation.warn('Spree::Order#create_proposed_fulfillments is deprecated and will be removed in Spree 6.1. Use #rebuild_fulfillments! instead.')- rebuild_fulfillments!- end-- # @deprecated Use {#rebuild_fulfillments!}; removed in 6.1.- def create_proposed_shipments- Spree::Deprecation.warn('Spree::Order#create_proposed_shipments is deprecated and will be removed in Spree 6.1. Use #rebuild_fulfillments! instead.')- rebuild_fulfillments!- end-- # @deprecated Use {#delivery_step_required?}; removed in 6.1.- def delivery_required?- Spree::Deprecation.warn('Spree::Order#delivery_required? is deprecated and will be removed in Spree 6.1. Use #delivery_step_required? (delivery-step applicability) or #shipping_address_required? (address collection) instead.')- delivery_step_required?- end-- # @deprecated Use {#shipping_address_required?}; removed in 6.1.- def requires_ship_address?- Spree::Deprecation.warn('Spree::Order#requires_ship_address? is deprecated and will be removed in Spree 6.1. Use #shipping_address_required? instead.')- shipping_address_required?- end-# Resolves the routing strategy from the channel override first, then the# store default. Only a registered Spree::OrderRouting::Strategy::Base# subclass is used; any other value (an unregistered/typo'd class, or a@@ -1064,12 +988,6 @@ module Spreeendend- # @deprecated Use {#ensure_updated_fulfillments}; removed in 6.1.- def ensure_updated_shipments- Spree::Deprecation.warn('Spree::Order#ensure_updated_fulfillments is deprecated and will be removed in Spree 6.1. Use #ensure_updated_fulfillments instead.')- ensure_updated_fulfillments- end-# Re-quotes every fulfillment for the given audience.## @param audience [Symbol] {Spree::DeliveryMethod::STOREFRONT} (default)@@ -1085,11 +1003,6 @@ module Spreerefresh_delivery_rates(audience)end- def set_shipments_cost- Spree::Deprecation.warn('Spree::Order#set_shipments_cost is deprecated and will be removed in Spree 6.1l. Please use set_fulfillments_cost instead')- set_fulfillments_cost- end-def set_fulfillments_costfulfillments.each(&:update_amounts)recalculate_totals!@@ -1249,11 +1162,6 @@ module Spreecsv_linesend- def all_line_items- Spree::Deprecation.warn('Spree::Order#all_line_items is deprecated and will be removed in Spree 6.1. Please use Spree::Order#line_items instead')- line_items- end-private# An order placed in a split checkout owns no payments, so its money is@@ -1338,12 +1246,6 @@ module Spreeendend- def collect_payment_methods- Spree::Deprecation.warn('`Order#collect_payment_methods` is deprecated and will be removed in Spree 6.1. Use `payment_methods` instead.')-- payment_methods- end-def credit_card_nil_payment?(attributes)payments.store_credits.present? && attributes[:amount].to_f.zero?enddiff --git a/spree/core/app/models/spree/payment/gateway_options.rb b/spree/core/app/models/spree/payment/gateway_options.rbindex c90915c3eb..4ae05cc7fd 100644--- a/spree/core/app/models/spree/payment/gateway_options.rb+++ b/spree/core/app/models/spree/payment/gateway_options.rb@@ -53,7 +53,7 @@ module Spreeenddef shipping- order.ship_total * exchange_multiplier+ order.delivery_total * exchange_multiplierenddef taxdiff --git a/spree/core/app/presenters/spree/csv/order_line_item_presenter.rb b/spree/core/app/presenters/spree/csv/order_line_item_presenter.rbindex 231085e937..2f43f6e196 100644--- a/spree/core/app/presenters/spree/csv/order_line_item_presenter.rb+++ b/spree/core/app/presenters/spree/csv/order_line_item_presenter.rb@@ -97,7 +97,7 @@ module Spreeindex.zero? ? order.status : nil,index.zero? ? order.currency : nil,index.zero? ? order.item_total.to_f : nil,- index.zero? ? order.shipment_total.to_f : nil,+ index.zero? ? order.delivery_total.to_f : nil,index.zero? ? order.tax_total.to_f : nil,index.zero? ? order.included_tax_total.positive? : nil,index.zero? ? (order.discount_total.negative? || line_item.discount_total.negative?) : nil,diff --git a/spree/core/app/services/spree/carts/create.rb b/spree/core/app/services/spree/carts/create.rbindex a845db051b..ffac1b6acc 100644--- a/spree/core/app/services/spree/carts/create.rb+++ b/spree/core/app/services/spree/carts/create.rb@@ -9,8 +9,14 @@ module Spreestore = @params.delete(:store)return failure(:store_is_required) if store.nil?+ customer = @params.delete(:customer)+ if @params.key?(:user)+ Spree::Deprecation.warn('Passing user: to Spree::Carts::Create is deprecated and will be removed in Spree 6.1. Pass customer: instead.')+ customer ||= @params.delete(:user)+ end+cart = store.carts.create!(- user: @params.delete(:user),+ customer: customer,market: @params.delete(:market) || Spree::Current.market,channel: @params.delete(:channel) || Spree::Current.channel,currency: @params.delete(:currency) || store.default_currency,diff --git a/spree/core/lib/spree/testing_support/factories/order_factory.rb b/spree/core/lib/spree/testing_support/factories/order_factory.rbindex 6debf057d8..d6da11cabf 100644--- a/spree/core/lib/spree/testing_support/factories/order_factory.rb+++ b/spree/core/lib/spree/testing_support/factories/order_factory.rb@@ -39,7 +39,7 @@ FactoryBot.define docreate(:line_item, order: order, price: evaluator.line_items_price)order.line_items.reload # to ensure order.line_items is accessible after- order.update_column(:item_count, order.line_items.count)+ order.update_column(:total_quantity, order.line_items.count)order.reloadendenddiff --git a/spree/core/spec/models/concerns/spree/purchase/deprecated_aliases_spec.rb b/spree/core/spec/models/concerns/spree/purchase/deprecated_aliases_spec.rbnew file mode 100644index 0000000000..77c7300730--- /dev/null+++ b/spree/core/spec/models/concerns/spree/purchase/deprecated_aliases_spec.rb@@ -0,0 +1,74 @@+require 'spec_helper'++RSpec.shared_examples 'a host of the 6.0 purchase renames' do+ before { allow(Spree::Deprecation).to receive(:warn) }++ Spree::Purchase::DeprecatedAliases::RENAMED_ATTRIBUTES.each do |legacy_name, current_name|+ describe "##{legacy_name}" do+ it "reads and writes ##{current_name} with a warning" do+ value = current_name == :customer_note ? 'Leave at the door' : 7++ record.public_send(:"#{legacy_name}=", value)++ expect(record.public_send(current_name)).to eq(value)+ expect(record.public_send(legacy_name)).to eq(value)+ expect(Spree::Deprecation).to have_received(:warn).with(/#{record.class.name}##{legacy_name}= is deprecated.*##{current_name}=/)+ expect(Spree::Deprecation).to have_received(:warn).with(/#{record.class.name}##{legacy_name} is deprecated.*##{current_name} instead/)+ end+ end+ end++ it 'resolves a renamed column in queries' do+ record.update!(discount_total: -5)++ expect(record.class.where(promo_total: -5)).to include(record)+ end++ it 'forwards renamed methods to their replacement with a warning' do+ record.discount_total = -5++ expect(record.display_promo_total).to eq(record.display_discount_total)+ expect(Spree::Deprecation).to have_received(:warn).with(/display_promo_total is deprecated.*#display_discount_total/)+ end++ it 'forwards arguments of renamed methods' do+ customer = build(:user)+ allow(record).to receive(:associate_customer!)++ record.associate_user!(customer, false)++ expect(record).to have_received(:associate_customer!).with(customer, false)+ end++ it 'answers the legacy payment method readers with #payment_methods' do+ allow(record).to receive(:payment_methods).and_return([:payment_method])++ expect(record.available_payment_methods(record.store)).to eq([:payment_method])+ expect(record.collect_frontend_payment_methods).to eq([:payment_method])+ expect(Spree::Deprecation).to have_received(:warn).with(/available_payment_methods is deprecated.*#payment_methods/)+ end++ it 'keeps the user alias for the customer' do+ customer = create(:user)++ record.user = customer++ expect(record.customer).to eq(customer)+ expect(record.user_id).to eq(customer.id)+ expect(Spree::Deprecation).to have_received(:warn).with(/#{record.class.name}#user= is deprecated/)+ end+end++RSpec.describe Spree::Purchase::DeprecatedAliases do+ context 'included in Spree::Cart' do+ let(:record) { create(:cart, store: @default_store) }++ it_behaves_like 'a host of the 6.0 purchase renames'+ end++ context 'included in Spree::Order' do+ let(:record) { create(:order, store: @default_store) }++ it_behaves_like 'a host of the 6.0 purchase renames'+ end+enddiff --git a/spree/core/spec/models/spree/payment/gateway_options_spec.rb b/spree/core/spec/models/spree/payment/gateway_options_spec.rbindex afd4c5b0e0..6ae66107e4 100644--- a/spree/core/spec/models/spree/payment/gateway_options_spec.rb+++ b/spree/core/spec/models/spree/payment/gateway_options_spec.rb@@ -28,7 +28,7 @@ RSpec.describe Spree::Payment::GatewayOptions, type: :model docustomer_id: 144,last_ip_address: '0.0.0.0',number: 'R1444',- ship_total: '12.44'.to_d,+ delivery_total: '12.44'.to_d,additional_tax_total: '1.53'.to_d,item_total: '15.11'.to_d,discount_total: '2.57'.to_d,diff --git a/spree/core/spec/services/spree/carts/create_spec.rb b/spree/core/spec/services/spree/carts/create_spec.rbindex 597fac0ac2..bc886297ca 100644--- a/spree/core/spec/services/spree/carts/create_spec.rb+++ b/spree/core/spec/services/spree/carts/create_spec.rb@@ -4,14 +4,14 @@ module Spreedescribe Carts::Create dosubject { described_class }- let(:user) { create :user }+ let(:customer) { create :user }let(:store) { create :store, default_currency: 'EUR' }let(:currency) { 'USD' }let(:metadata) { { prop1: 2 } }let(:expected) { Spree::Cart.first }context 'create an order' do- let(:execute) { subject.call params: { user: user, store: store, currency: currency, metadata: metadata } }+ let(:execute) { subject.call params: { customer: customer, store: store, currency: currency, metadata: metadata } }let(:value) { execute.value }it do@@ -23,14 +23,14 @@ module Spreeendcontext 'create an order with store currency' do- let(:execute) { subject.call params: { user: user, store: store } }+ let(:execute) { subject.call params: { customer: customer, store: store } }let(:value) { execute.value }it doexpect { execute }.to change(Spree::Cart, :count)expect(execute).to be_successexpect(value).to eq expected- expect(expected.customer).to eq user+ expect(expected.customer).to eq customerexpect(expected.store).to eq storeexpect(expected.currency).to eq 'EUR'expect(expected.token).to be_present@@ -38,7 +38,7 @@ module Spreeendcontext 'create an order with locale' do- let(:execute) { subject.call params: { user: user, store: store, currency: currency, locale: 'fr' } }+ let(:execute) { subject.call params: { customer: customer, store: store, currency: currency, locale: 'fr' } }let(:value) { execute.value }before do@@ -53,7 +53,7 @@ module Spreeendcontext 'create an order with default locale from Spree::Current' do- let(:execute) { subject.call params: { user: user, store: store, currency: currency } }+ let(:execute) { subject.call params: { customer: customer, store: store, currency: currency } }let(:value) { execute.value }before do@@ -69,7 +69,7 @@ module Spreecontext 'create an order with market from Spree::Current' dolet(:market) { create(:market, store: store) }- let(:execute) { subject.call params: { user: user, store: store, currency: currency } }+ let(:execute) { subject.call params: { customer: customer, store: store, currency: currency } }let(:value) { execute.value }before do@@ -84,7 +84,7 @@ module Spreecontext 'create an order with explicit market' dolet(:market) { create(:market, store: store) }- let(:execute) { subject.call params: { user: user, store: store, currency: currency, market: market } }+ let(:execute) { subject.call params: { customer: customer, store: store, currency: currency, market: market } }let(:value) { execute.value }it 'uses the explicit market' do@@ -93,9 +93,20 @@ module Spreeendend+ context 'with the legacy user param' do+ it 'assigns the customer with a deprecation warning' do+ expect(Spree::Deprecation).to receive(:warn).with(/Pass customer: instead/)++ result = subject.call(params: { user: customer, store: store })++ expect(result).to be_success+ expect(result.value.customer).to eq customer+ end+ end+context 'returns failure when no store is passed' dolet!(:default_store) { create :store, default: true }- let(:execute) { subject.call params: { user: user, store: nil } }+ let(:execute) { subject.call params: { customer: customer, store: nil } }let(:value) { execute.value }it do@@ -122,7 +133,7 @@ module Spree]end- let(:execute) { subject.call params: { user: user, store: store, currency: currency, items: items } }+ let(:execute) { subject.call params: { customer: customer, store: store, currency: currency, items: items } }let(:value) { execute.value }it 'creates order with line items' do@@ -142,7 +153,7 @@ module Spreeendlet(:items) { [{ variant_id: variant.prefixed_id }] }- let(:execute) { subject.call params: { user: user, store: store, currency: currency, items: items } }+ let(:execute) { subject.call params: { customer: customer, store: store, currency: currency, items: items } }it 'defaults quantity to 1' doexpect(execute).to be_success