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
Fixed Countries/States API endpoints
Damian Legawiec139ef639939f
diff --git a/api/app/controllers/spree/api/v3/store/countries_controller.rb b/api/app/controllers/spree/api/v3/store/countries_controller.rbindex 1163f93db9..7068ce8500 100644--- a/api/app/controllers/spree/api/v3/store/countries_controller.rb+++ b/api/app/controllers/spree/api/v3/store/countries_controller.rb@@ -33,22 +33,18 @@ module Spreeenddef serialize_country(country, include_states: false)- data = {- iso: country.iso,- iso3: country.iso3,- name: country.name,- states_required: country.states_required,- zipcode_required: country.zipcode_required- }+ data = Spree.api.country_serializer.new(country, params: { includes: [] }).to_hif include_states- data[:states] = country.states.order(:name).map do |state|- { abbr: state.abbr, name: state.name }- end+ data[:states] = serialize_collection(country.states.order(:name), Spree.api.state_serializer)enddataend++ def serialize_collection(collection, serializer_class)+ collection.map { |item| serializer_class.new(item).to_h }+ endendendenddiff --git a/api/spec/controllers/spree/api/v3/store/countries_controller_spec.rb b/api/spec/controllers/spree/api/v3/store/countries_controller_spec.rbindex 2c185f631e..c4c2e0c05b 100644--- a/api/spec/controllers/spree/api/v3/store/countries_controller_spec.rb+++ b/api/spec/controllers/spree/api/v3/store/countries_controller_spec.rb@@ -56,7 +56,7 @@ RSpec.describe Spree::Api::V3::Store::CountriesController, type: :controller doexpect(response).to have_http_status(:ok)expect(json_response['states']).to be_present- expect(json_response['states'].first['iso']).to eq(state.abbr)+ expect(json_response['states'].first['abbr']).to eq(state.abbr)expect(json_response['states'].first['name']).to eq(state.name)end