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 Taxon Products API scope (#13606)
Damian Legawiec3f7635ec6859
diff --git a/backend/engines/api/app/controllers/spree/api/v3/store/taxons/products_controller.rb b/backend/engines/api/app/controllers/spree/api/v3/store/taxons/products_controller.rbindex e0158504eb..f5a738bfcc 100644--- a/backend/engines/api/app/controllers/spree/api/v3/store/taxons/products_controller.rb+++ b/backend/engines/api/app/controllers/spree/api/v3/store/taxons/products_controller.rb@@ -13,14 +13,7 @@ module Spreeenddef scope- Spree::Product.- in_taxon(@taxon).- for_store(current_store).- accessible_by(current_ability, :show).- available(Time.current, Spree::Current.currency).- includes(scope_includes).- preload_associations_lazily.- i18n+ super.in_taxon(@taxon)endprivatediff --git a/backend/engines/api/spec/controllers/spree/api/v3/store/taxons/products_controller_spec.rb b/backend/engines/api/spec/controllers/spree/api/v3/store/taxons/products_controller_spec.rbindex 21a5f984ff..d1dd552532 100644--- a/backend/engines/api/spec/controllers/spree/api/v3/store/taxons/products_controller_spec.rb+++ b/backend/engines/api/spec/controllers/spree/api/v3/store/taxons/products_controller_spec.rb@@ -12,6 +12,7 @@ RSpec.describe Spree::Api::V3::Store::Taxons::ProductsController, type: :controllet!(:product_in_taxon) { create(:product, stores: [store], taxons: [taxon]) }let!(:product_in_child_taxon) { create(:product, stores: [store], taxons: [child_taxon]) }let!(:product_not_in_taxon) { create(:product, stores: [store]) }+ let!(:inactive_product_in_taxon) { create(:product, stores: [store], taxons: [taxon], status: 'draft') }let!(:other_store) { create(:store) }let!(:other_taxonomy) { create(:taxonomy, store: other_store) }@@ -23,12 +24,13 @@ RSpec.describe Spree::Api::V3::Store::Taxons::ProductsController, type: :controldescribe 'GET #index' docontext 'finding taxon by permalink' do- it 'returns products belonging to the taxon' do+ it 'returns active products belonging to the taxon' doget :index, params: { taxon_id: taxon.permalink }expect(response).to have_http_status(:ok)expect(json_response['data'].pluck('id')).to include(product_in_taxon.prefixed_id)expect(json_response['data'].pluck('id')).not_to include(product_not_in_taxon.prefixed_id)+ expect(json_response['data'].pluck('id')).not_to include(inactive_product_in_taxon.prefixed_id)endit 'returns products from descendant taxons' do