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.

Fixed relationships for Stock Location serializer in Platform API (#11492)

Damian Legawiece0f93ce1252b
diff --git a/api/app/serializers/spree/api/v2/platform/stock_location_serializer.rb b/api/app/serializers/spree/api/v2/platform/stock_location_serializer.rb
index ea07116570..f4b0967932 100644
--- a/api/app/serializers/spree/api/v2/platform/stock_location_serializer.rb
+++ b/api/app/serializers/spree/api/v2/platform/stock_location_serializer.rb
@@ -6,9 +6,7 @@ module Spree
include ResourceSerializerConcern
attributes :name
-
- has_many :shipments
- has_many :stock_items
+ belongs_to :country
end
end
end
diff --git a/api/spec/serializers/spree/api/v2/platform/stock_location_serializer_spec.rb b/api/spec/serializers/spree/api/v2/platform/stock_location_serializer_spec.rb
index fad1e40eb7..983423e940 100644
--- a/api/spec/serializers/spree/api/v2/platform/stock_location_serializer_spec.rb
+++ b/api/spec/serializers/spree/api/v2/platform/stock_location_serializer_spec.rb
@@ -5,9 +5,9 @@ describe Spree::Api::V2::Platform::StockLocationSerializer do
subject { described_class.new(resource, params: serializer_params).serializable_hash }
- let(:resource) { create(:stock_location_with_items, shipments: [shipment]) }
+ let(:resource) { create(:stock_location, country: country) }
let(:type) { :stock_location }
- let(:shipment) { create(:shipment) }
+ let(:country) { create(:country) }
it do
expect(subject).to eq(
@@ -31,20 +31,11 @@ describe Spree::Api::V2::Platform::StockLocationSerializer do
zipcode: resource.zipcode
},
relationships: {
- shipments: {
- data: [{
- id: shipment.id.to_s,
- type: :shipment
- }]
- },
- stock_items: {
- data: [{
- id: resource.stock_items[0].id.to_s,
- type: :stock_item
- }, {
- id: resource.stock_items[1].id.to_s,
- type: :stock_item
- }]
+ country: {
+ data: {
+ id: country.id.to_s,
+ type: :country
+ }
}
}
}