Skip to content

armgit / spree

Public Imported from GitHub
0

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.

Drop the dead checkouts association on Store

Damian Legawiec13591cb3308d
diff --git a/spree/api/app/controllers/spree/api/v3/resource_controller.rb b/spree/api/app/controllers/spree/api/v3/resource_controller.rb
index 354d41120d..4347c29759 100644
--- a/spree/api/app/controllers/spree/api/v3/resource_controller.rb
+++ b/spree/api/app/controllers/spree/api/v3/resource_controller.rb
@@ -213,8 +213,8 @@ module Spree
end
return reflections.first&.name if reflections.one?
- # More than one association reaches this model — Store has both
- # `orders` and `checkouts` for Spree::Order — so the conventional
+ # More than one association reaches this model — a deprecated twin
+ # such as `shipments` beside `fulfillments` — so the conventional
# name decides which one a create belongs on.
conventional = model_class.model_name.element.pluralize.to_sym
reflections.find { |reflection| reflection.name == conventional }&.name
diff --git a/spree/api/spec/controllers/spree/api/v3/resource_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/resource_controller_spec.rb
index 11f9902c13..337c59e605 100644
--- a/spree/api/spec/controllers/spree/api/v3/resource_controller_spec.rb
+++ b/spree/api/spec/controllers/spree/api/v3/resource_controller_spec.rb
@@ -105,11 +105,14 @@ RSpec.describe Spree::Api::V3::ResourceController, type: :controller do
# Several associations reach these, including the deprecated twins this
# release introduced; the conventional name picks the right one.
it 'breaks a tie with the conventional name' do
- expect(resolve(Spree::Order)).to eq(:orders)
expect(resolve(Spree::Fulfillment)).to eq(:fulfillments)
expect(resolve(Spree::CustomField)).to eq(:custom_fields)
end
+ it 'resolves an order to orders' do
+ expect(resolve(Spree::Order)).to eq(:orders)
+ end
+
# Global data has no store association at all, so it builds on the class.
it 'declines a model the store does not own' do
expect(resolve(Spree::OptionType)).to be_nil
diff --git a/spree/core/app/models/spree/store.rb b/spree/core/app/models/spree/store.rb
index 7185530549..4db0a6737f 100644
--- a/spree/core/app/models/spree/store.rb
+++ b/spree/core/app/models/spree/store.rb
@@ -122,7 +122,6 @@ module Spree
# Associations
#
has_many :carts, class_name: 'Spree::Cart', inverse_of: :store, dependent: :destroy
- has_many :checkouts, -> { incomplete }, class_name: 'Spree::Order', inverse_of: :store
has_many :orders, class_name: 'Spree::Order'
has_many :line_items, through: :orders, class_name: 'Spree::LineItem'
has_many :digital_links, through: :line_items, class_name: 'Spree::DigitalLink'