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 using prefixed IDs in Store API
Damian Legawieca5971cadbdb9
diff --git a/api/app/controllers/spree/api/v3/store/addresses_controller.rb b/api/app/controllers/spree/api/v3/store/addresses_controller.rbindex 03227a2dc3..17397a5deb 100644--- a/api/app/controllers/spree/api/v3/store/addresses_controller.rb+++ b/api/app/controllers/spree/api/v3/store/addresses_controller.rb@@ -2,7 +2,7 @@ module Spreemodule Apimodule V3module Store- class AddressesController < Store::ResourceController+ class AddressesController < ResourceControllerprepend_before_action :require_authentication!# POST /api/v3/store/customers/me/addressesdiff --git a/api/app/controllers/spree/api/v3/store/credit_cards_controller.rb b/api/app/controllers/spree/api/v3/store/credit_cards_controller.rbindex 4700243e47..7da2f0da8a 100644--- a/api/app/controllers/spree/api/v3/store/credit_cards_controller.rb+++ b/api/app/controllers/spree/api/v3/store/credit_cards_controller.rb@@ -2,7 +2,7 @@ module Spreemodule Apimodule V3module Store- class CreditCardsController < Store::ResourceController+ class CreditCardsController < ResourceControllerprepend_before_action :require_authentication!protecteddiff --git a/api/app/controllers/spree/api/v3/store/digitals_controller.rb b/api/app/controllers/spree/api/v3/store/digitals_controller.rbindex bf2d480740..f2b37dbccd 100644--- a/api/app/controllers/spree/api/v3/store/digitals_controller.rb+++ b/api/app/controllers/spree/api/v3/store/digitals_controller.rb@@ -2,7 +2,7 @@ module Spreemodule Apimodule V3module Store- class DigitalsController < Store::ResourceController+ class DigitalsController < ResourceController# GET /api/v3/store/digitals/:id?token=...def showif @resource.authorize!diff --git a/api/app/controllers/spree/api/v3/store/orders/line_items_controller.rb b/api/app/controllers/spree/api/v3/store/orders/line_items_controller.rbindex 937bfadbc4..f40ba2ef5b 100644--- a/api/app/controllers/spree/api/v3/store/orders/line_items_controller.rb+++ b/api/app/controllers/spree/api/v3/store/orders/line_items_controller.rb@@ -3,7 +3,7 @@ module Spreemodule V3module Storemodule Orders- class LineItemsController < Store::ResourceController+ class LineItemsController < ResourceControllerinclude Spree::Api::V3::OrderConcernskip_before_action :set_resource@@ -70,15 +70,7 @@ module Spreeenddef variant- variants = current_store.variants.accessible_by(current_ability)- variant_id = permitted_params[:variant_id]-- # Support both prefix_id (variant_xxx) and database ID- if variant_id.to_s.start_with?('variant_')- variants.find_by!(prefix_id: variant_id)- else- variants.find(variant_id)- end+ @variant ||= current_store.variants.accessible_by(current_ability).find_by!(prefix_id: permitted_params[:variant_id])enddef model_classdiff --git a/api/app/controllers/spree/api/v3/store/orders/promotions_controller.rb b/api/app/controllers/spree/api/v3/store/orders/promotions_controller.rbindex b1b14caa5c..dc8059d73e 100644--- a/api/app/controllers/spree/api/v3/store/orders/promotions_controller.rb+++ b/api/app/controllers/spree/api/v3/store/orders/promotions_controller.rb@@ -3,7 +3,7 @@ module Spreemodule V3module Storemodule Orders- class PromotionsController < Store::ResourceController+ class PromotionsController < ResourceControllerinclude Spree::Api::V3::OrderConcernbefore_action :authorize_order_access!@@ -45,7 +45,7 @@ module Spreeenddef promotion_handler- @promotion_handler ||= Spree::PromotionHandler::Coupon.new(@parent)+ @promotion_handler ||= Spree.coupon_handler.new(@parent)enddef permitted_paramsdiff --git a/api/app/controllers/spree/api/v3/store/orders/shipments_controller.rb b/api/app/controllers/spree/api/v3/store/orders/shipments_controller.rbindex f2f4fe4a13..33f4581883 100644--- a/api/app/controllers/spree/api/v3/store/orders/shipments_controller.rb+++ b/api/app/controllers/spree/api/v3/store/orders/shipments_controller.rb@@ -3,7 +3,7 @@ module Spreemodule V3module Storemodule Orders- class ShipmentsController < Store::ResourceController+ class ShipmentsController < ResourceControllerinclude Spree::Api::V3::OrderConcernbefore_action :authorize_order_access!diff --git a/api/app/controllers/spree/api/v3/store/orders/store_credits_controller.rb b/api/app/controllers/spree/api/v3/store/orders/store_credits_controller.rbindex e34adde07d..9dcf6ecc95 100644--- a/api/app/controllers/spree/api/v3/store/orders/store_credits_controller.rb+++ b/api/app/controllers/spree/api/v3/store/orders/store_credits_controller.rb@@ -12,7 +12,7 @@ module Spree# POST /api/v3/store/orders/:order_id/store_creditsdef create- result = add_store_credit_service.call(+ result = Spree.checkout_add_store_credit_service.call(order: @order,amount: params[:amount].try(:to_f))@@ -26,7 +26,7 @@ module Spree# DELETE /api/v3/store/orders/:order_id/store_creditsdef destroy- result = remove_store_credit_service.call(order: @order)+ result = Spree.checkout_remove_store_credit_service.call(order: @order)if result.success?render json: serialize_resource(@order.reload)@@ -45,14 +45,6 @@ module Spreedef serializer_classSpree.api.order_serializerend-- def add_store_credit_service- Spree::Api::Dependencies.storefront_checkout_add_store_credit_service.constantize- end-- def remove_store_credit_service- Spree::Api::Dependencies.storefront_checkout_remove_store_credit_service.constantize- endendendenddiff --git a/api/app/controllers/spree/api/v3/store/orders_controller.rb b/api/app/controllers/spree/api/v3/store/orders_controller.rbindex 5e7088ed7e..943c8b5f46 100644--- a/api/app/controllers/spree/api/v3/store/orders_controller.rb+++ b/api/app/controllers/spree/api/v3/store/orders_controller.rb@@ -2,7 +2,7 @@ module Spreemodule Apimodule V3module Store- class OrdersController < Store::ResourceController+ class OrdersController < ResourceControllerinclude Spree::Api::V3::OrderConcern# Skip base controller's set_resource and define our own complete list@@ -25,7 +25,15 @@ module Spree# PATCH /api/v3/store/orders/:iddef update- if @order.update(permitted_params)+ result = Spree.checkout_update_service.call(+ order: @order,+ params: params,+ # defined in https://github.com/spree/spree/blob/main/core/lib/spree/core/controller_helpers/strong_parameters.rb#L19+ permitted_attributes: permitted_checkout_attributes,+ request_env: request.headers.env+ )++ if result.success?render json: serialize_resource(@order.reload)elserender_errors(@order.errors)@@ -34,7 +42,7 @@ module Spree# PATCH /api/v3/store/orders/:id/nextdef next- result = next_service.call(order: @order)+ result = Spree.checkout_next_service.call(order: @order)if result.success?render json: serialize_resource(@order)@@ -45,7 +53,7 @@ module Spree# PATCH /api/v3/store/orders/:id/advancedef advance- result = advance_service.call(order: @order)+ result = Spree.checkout_advance_service.call(order: @order)if result.success?render json: serialize_resource(@order)@@ -56,7 +64,7 @@ module Spree# PATCH /api/v3/store/orders/:id/completedef complete- result = complete_service.call(order: @order)+ result = Spree.checkout_complete_service.call(order: @order)if result.success?render json: serialize_resource(@order)@@ -102,22 +110,6 @@ module Spreedef permitted_paramsparams.require(:order).permit(Spree::PermittedAttributes.checkout_attributes)end-- def update_service- Spree::Api::Dependencies.storefront_checkout_update_service.constantize- end-- def next_service- Spree::Api::Dependencies.storefront_checkout_next_service.constantize- end-- def advance_service- Spree::Api::Dependencies.storefront_checkout_advance_service.constantize- end-- def complete_service- Spree::Api::Dependencies.storefront_checkout_complete_service.constantize- endendendenddiff --git a/api/app/controllers/spree/api/v3/store/payment_sources_controller.rb b/api/app/controllers/spree/api/v3/store/payment_sources_controller.rbindex 0e336a7269..15116cc22e 100644--- a/api/app/controllers/spree/api/v3/store/payment_sources_controller.rb+++ b/api/app/controllers/spree/api/v3/store/payment_sources_controller.rb@@ -2,7 +2,7 @@ module Spreemodule Apimodule V3module Store- class PaymentSourcesController < Store::ResourceController+ class PaymentSourcesController < ResourceControllerprepend_before_action :require_authentication!protecteddiff --git a/api/app/controllers/spree/api/v3/store/products_controller.rb b/api/app/controllers/spree/api/v3/store/products_controller.rbindex 61c4c6346a..a007bf72bf 100644--- a/api/app/controllers/spree/api/v3/store/products_controller.rb+++ b/api/app/controllers/spree/api/v3/store/products_controller.rb@@ -2,7 +2,7 @@ module Spreemodule Apimodule V3module Store- class ProductsController < Store::ResourceController+ class ProductsController < ResourceControllerprotecteddef model_classdiff --git a/api/app/controllers/spree/api/v3/store/stores_controller.rb b/api/app/controllers/spree/api/v3/store/stores_controller.rbindex c91dae964c..9466df41d0 100644--- a/api/app/controllers/spree/api/v3/store/stores_controller.rb+++ b/api/app/controllers/spree/api/v3/store/stores_controller.rb@@ -2,7 +2,7 @@ module Spreemodule Apimodule V3module Store- class StoresController < Store::ResourceController+ class StoresController < ResourceController# Public endpoint - no authentication required# GET /api/v3/store/storediff --git a/api/app/controllers/spree/api/v3/store/taxonomies_controller.rb b/api/app/controllers/spree/api/v3/store/taxonomies_controller.rbindex 3b2c914f46..de5f015e40 100644--- a/api/app/controllers/spree/api/v3/store/taxonomies_controller.rb+++ b/api/app/controllers/spree/api/v3/store/taxonomies_controller.rb@@ -2,7 +2,7 @@ module Spreemodule Apimodule V3module Store- class TaxonomiesController < Store::ResourceController+ class TaxonomiesController < ResourceControllerprotecteddef model_classdiff --git a/api/app/controllers/spree/api/v3/store/taxons_controller.rb b/api/app/controllers/spree/api/v3/store/taxons_controller.rbindex ebfc41c717..f407f849ce 100644--- a/api/app/controllers/spree/api/v3/store/taxons_controller.rb+++ b/api/app/controllers/spree/api/v3/store/taxons_controller.rb@@ -2,7 +2,7 @@ module Spreemodule Apimodule V3module Store- class TaxonsController < Store::ResourceController+ class TaxonsController < ResourceControllerprotecteddef model_classdiff --git a/api/app/controllers/spree/api/v3/store/wishlist_items_controller.rb b/api/app/controllers/spree/api/v3/store/wishlist_items_controller.rbindex 844a00e6c6..c86e1749cd 100644--- a/api/app/controllers/spree/api/v3/store/wishlist_items_controller.rb+++ b/api/app/controllers/spree/api/v3/store/wishlist_items_controller.rb@@ -2,7 +2,7 @@ module Spreemodule Apimodule V3module Store- class WishlistItemsController < Store::ResourceController+ class WishlistItemsController < ResourceControllerprepend_before_action :require_authentication!protecteddiff --git a/api/app/controllers/spree/api/v3/store/wishlists_controller.rb b/api/app/controllers/spree/api/v3/store/wishlists_controller.rbindex 7a8cbbb9f1..bd6776b6de 100644--- a/api/app/controllers/spree/api/v3/store/wishlists_controller.rb+++ b/api/app/controllers/spree/api/v3/store/wishlists_controller.rb@@ -2,7 +2,7 @@ module Spreemodule Apimodule V3module Store- class WishlistsController < Store::ResourceController+ class WishlistsController < ResourceControllerprepend_before_action :require_authentication!# POST /api/v3/store/wishlistsdiff --git a/api/spec/controllers/spree/api/v3/store/customers_controller_spec.rb b/api/spec/controllers/spree/api/v3/store/customers_controller_spec.rbindex dc2f2c7206..8ea8f283f2 100644--- a/api/spec/controllers/spree/api/v3/store/customers_controller_spec.rb+++ b/api/spec/controllers/spree/api/v3/store/customers_controller_spec.rb@@ -15,7 +15,7 @@ RSpec.describe Spree::Api::V3::Store::CustomersController, type: :controller doget :show, params: { id: 'me' }expect(response).to have_http_status(:ok)- expect(json_response['id']).to eq(user.id)+ expect(json_response['id']).to eq(user.prefix_id)expect(json_response['email']).to eq(user.email)enddiff --git a/api/spec/controllers/spree/api/v3/store/orders/line_items_controller_spec.rb b/api/spec/controllers/spree/api/v3/store/orders/line_items_controller_spec.rbindex 806f8fa75b..5eec7536a4 100644--- a/api/spec/controllers/spree/api/v3/store/orders/line_items_controller_spec.rb+++ b/api/spec/controllers/spree/api/v3/store/orders/line_items_controller_spec.rb@@ -12,28 +12,29 @@ RSpec.describe Spree::Api::V3::Store::Orders::LineItemsController, type: :controbefore dorequest.headers['X-Spree-Api-Key'] = api_key.tokenrequest.headers['Authorization'] = "Bearer #{jwt_token}"+ request.headers['x-spree-order-token'] = order.tokenenddescribe 'POST #create' doit 'adds a line item to the order' doexpect {- post :create, params: { order_id: order.number, line_item: { variant_id: variant.id, quantity: 2 } }+ post :create, params: { order_id: order.number, line_item: { variant_id: variant.prefix_id, quantity: 2 } }}.to change(Spree::LineItem, :count).by(1)expect(response).to have_http_status(:created)- expect(json_response['variant_id']).to eq(variant.id)+ expect(json_response['variant_id']).to eq(variant.prefix_id)expect(json_response['quantity']).to eq(2)endit 'defaults quantity to 1' do- post :create, params: { order_id: order.number, line_item: { variant_id: variant.id } }+ post :create, params: { order_id: order.number, line_item: { variant_id: variant.prefix_id } }expect(response).to have_http_status(:created)expect(json_response['quantity']).to eq(1)endit 'updates order totals' do- post :create, params: { order_id: order.number, line_item: { variant_id: variant.id, quantity: 2 } }+ post :create, params: { order_id: order.number, line_item: { variant_id: variant.prefix_id, quantity: 2 } }expect(order.reload.item_total).to be > 0end@@ -45,13 +46,13 @@ RSpec.describe Spree::Api::V3::Store::Orders::LineItemsController, type: :controit 'adds line item with valid order token' dorequest.headers['X-Spree-Order-Token'] = guest_order.token- post :create, params: { order_id: guest_order.number, line_item: { variant_id: variant.id, quantity: 1 } }+ post :create, params: { order_id: guest_order.number, line_item: { variant_id: variant.prefix_id, quantity: 1 } }expect(response).to have_http_status(:created)endit 'returns forbidden without order token' do- post :create, params: { order_id: guest_order.number, line_item: { variant_id: variant.id, quantity: 1 } }+ post :create, params: { order_id: guest_order.number, line_item: { variant_id: variant.prefix_id, quantity: 1 } }expect(response).to have_http_status(:forbidden)expect(json_response['error']['code']).to eq('access_denied')@@ -71,7 +72,7 @@ RSpec.describe Spree::Api::V3::Store::Orders::LineItemsController, type: :controcontext 'error handling' doit 'returns not found for non-existent order' do- post :create, params: { order_id: 'invalid', line_item: { variant_id: variant.id, quantity: 1 } }+ post :create, params: { order_id: 'invalid', line_item: { variant_id: variant.prefix_id, quantity: 1 } }expect(response).to have_http_status(:not_found)expect(json_response['error']['code']).to eq('order_not_found')@@ -81,7 +82,7 @@ RSpec.describe Spree::Api::V3::Store::Orders::LineItemsController, type: :controit 'returns forbidden for other users order' doother_order = create(:order, store: store)- post :create, params: { order_id: other_order.number, line_item: { variant_id: variant.id, quantity: 1 } }+ post :create, params: { order_id: other_order.number, line_item: { variant_id: variant.prefix_id, quantity: 1 } }expect(response).to have_http_status(:forbidden)expect(json_response['error']['code']).to eq('access_denied')@@ -93,7 +94,7 @@ RSpec.describe Spree::Api::V3::Store::Orders::LineItemsController, type: :controlet!(:line_item) { create(:line_item, order: order, variant: variant, quantity: 1) }it 'updates line item quantity' do- patch :update, params: { order_id: order.number, id: line_item.id, line_item: { quantity: 5 } }+ patch :update, params: { order_id: order.number, id: line_item.prefix_id, line_item: { quantity: 5 } }expect(response).to have_http_status(:ok)expect(line_item.reload.quantity).to eq(5)@@ -101,7 +102,7 @@ RSpec.describe Spree::Api::V3::Store::Orders::LineItemsController, type: :controit 'updates order totals' dooriginal_total = order.item_total- patch :update, params: { order_id: order.number, id: line_item.id, line_item: { quantity: 5 } }+ patch :update, params: { order_id: order.number, id: line_item.prefix_id, line_item: { quantity: 5 } }expect(order.reload.item_total).to be > original_totalend@@ -119,7 +120,7 @@ RSpec.describe Spree::Api::V3::Store::Orders::LineItemsController, type: :controother_order = create(:order, store: store)other_line_item = create(:line_item, order: other_order, variant: variant)- patch :update, params: { order_id: other_order.number, id: other_line_item.id, line_item: { quantity: 5 } }+ patch :update, params: { order_id: other_order.number, id: other_line_item.prefix_id, line_item: { quantity: 5 } }expect(response).to have_http_status(:forbidden)expect(json_response['error']['code']).to eq('access_denied')@@ -132,7 +133,7 @@ RSpec.describe Spree::Api::V3::Store::Orders::LineItemsController, type: :controit 'removes line item from order' doexpect {- delete :destroy, params: { order_id: order.number, id: line_item.id }+ delete :destroy, params: { order_id: order.number, id: line_item.prefix_id }}.to change(Spree::LineItem, :count).by(-1)expect(response).to have_http_status(:no_content)@@ -140,7 +141,7 @@ RSpec.describe Spree::Api::V3::Store::Orders::LineItemsController, type: :controit 'updates order totals' doorder.update_columns(item_total: 100)- delete :destroy, params: { order_id: order.number, id: line_item.id }+ delete :destroy, params: { order_id: order.number, id: line_item.prefix_id }expect(order.reload.item_total).to eq(0)end@@ -158,7 +159,7 @@ RSpec.describe Spree::Api::V3::Store::Orders::LineItemsController, type: :controother_order = create(:order, store: store)other_line_item = create(:line_item, order: other_order, variant: variant)- delete :destroy, params: { order_id: other_order.number, id: other_line_item.id }+ delete :destroy, params: { order_id: other_order.number, id: other_line_item.prefix_id }expect(response).to have_http_status(:forbidden)expect(json_response['error']['code']).to eq('access_denied')diff --git a/api/spec/controllers/spree/api/v3/store/orders_controller_spec.rb b/api/spec/controllers/spree/api/v3/store/orders_controller_spec.rbindex b3465b42f5..a144f45ba9 100644--- a/api/spec/controllers/spree/api/v3/store/orders_controller_spec.rb+++ b/api/spec/controllers/spree/api/v3/store/orders_controller_spec.rb@@ -113,7 +113,7 @@ RSpec.describe Spree::Api::V3::Store::OrdersController, type: :controller doit 'returns order with expected attributes' doget :show, params: { id: order.number }- expect(json_response['id']).to eq(order.id)+ expect(json_response['id']).to eq(order.prefix_id)expect(json_response['number']).to eq(order.number)endenddiff --git a/api/spec/controllers/spree/api/v3/store/products_controller_spec.rb b/api/spec/controllers/spree/api/v3/store/products_controller_spec.rbindex 1155e600ea..60dd47d963 100644--- a/api/spec/controllers/spree/api/v3/store/products_controller_spec.rb+++ b/api/spec/controllers/spree/api/v3/store/products_controller_spec.rb@@ -58,7 +58,7 @@ RSpec.describe Spree::Api::V3::Store::ProductsController, type: :controller doget :indexids = json_response['data'].map { |p| p['id'] }- expect(ids).not_to include(other_store_product.id)+ expect(ids).not_to include(other_store_product.prefix_id)endenddiff --git a/api/spec/controllers/spree/api/v3/store/stores_controller_spec.rb b/api/spec/controllers/spree/api/v3/store/stores_controller_spec.rbindex 5b6f54f5e3..f8109e4537 100644--- a/api/spec/controllers/spree/api/v3/store/stores_controller_spec.rb+++ b/api/spec/controllers/spree/api/v3/store/stores_controller_spec.rb@@ -14,7 +14,7 @@ RSpec.describe Spree::Api::V3::Store::StoresController, type: :controller doget :currentexpect(response).to have_http_status(:ok)- expect(json_response['id']).to eq(store.id)+ expect(json_response['id']).to eq(store.prefix_id)endit 'returns store attributes' dodiff --git a/api/spec/controllers/spree/api/v3/store/taxonomies_controller_spec.rb b/api/spec/controllers/spree/api/v3/store/taxonomies_controller_spec.rbindex 259940828a..3049788505 100644--- a/api/spec/controllers/spree/api/v3/store/taxonomies_controller_spec.rb+++ b/api/spec/controllers/spree/api/v3/store/taxonomies_controller_spec.rb@@ -33,7 +33,7 @@ RSpec.describe Spree::Api::V3::Store::TaxonomiesController, type: :controller doget :indexids = json_response['data'].map { |t| t['id'] }- expect(ids).not_to include(other_store_taxonomy.id)+ expect(ids).not_to include(other_store_taxonomy.prefix_id)endit 'returns pagination metadata' do@@ -60,14 +60,14 @@ RSpec.describe Spree::Api::V3::Store::TaxonomiesController, type: :controller doget :show, params: { id: taxonomy.id }expect(response).to have_http_status(:ok)- expect(json_response['id']).to eq(taxonomy.id)+ expect(json_response['id']).to eq(taxonomy.prefix_id)expect(json_response['name']).to eq(taxonomy.name)endit 'returns taxonomy with its attributes' doget :show, params: { id: taxonomy.id }- expect(json_response['id']).to eq(taxonomy.id)+ expect(json_response['id']).to eq(taxonomy.prefix_id)expect(json_response['name']).to be_presentenddiff --git a/api/spec/controllers/spree/api/v3/store/wishlist_items_controller_spec.rb b/api/spec/controllers/spree/api/v3/store/wishlist_items_controller_spec.rbindex 4ab1120cfd..9412afa464 100644--- a/api/spec/controllers/spree/api/v3/store/wishlist_items_controller_spec.rb+++ b/api/spec/controllers/spree/api/v3/store/wishlist_items_controller_spec.rb@@ -21,23 +21,17 @@ RSpec.describe Spree::Api::V3::Store::WishlistItemsController, type: :controllerit 'adds item to wishlist' doexpect {- post :create, params: { wishlist_id: wishlist.id, wished_item: { variant_id: new_variant.id, quantity: 1 } }+ post :create, params: { wishlist_id: wishlist.prefix_id, wished_item: { variant_id: new_variant.prefix_id, quantity: 3 } }}.to change(Spree::WishedItem, :count).by(1)expect(response).to have_http_status(:created)- expect(json_response['variant_id']).to eq(new_variant.id)- end-- it 'sets correct quantity' do- post :create, params: { wishlist_id: wishlist.id, wished_item: { variant_id: new_variant.id, quantity: 3 } }-- expect(response).to have_http_status(:created)+ expect(json_response['variant_id']).to eq(new_variant.prefix_id)expect(json_response['quantity']).to eq(3)endcontext 'validation errors' doit 'returns errors for missing variant_id' do- post :create, params: { wishlist_id: wishlist.id, wished_item: { quantity: 1 } }+ post :create, params: { wishlist_id: wishlist.prefix_id, wished_item: { quantity: 1 } }expect(response).to have_http_status(:unprocessable_entity)expect(json_response['error']['code']).to eq('validation_error')@@ -45,7 +39,7 @@ RSpec.describe Spree::Api::V3::Store::WishlistItemsController, type: :controllerendit 'returns errors for invalid variant_id' do- post :create, params: { wishlist_id: wishlist.id, wished_item: { variant_id: 0, quantity: 1 } }+ post :create, params: { wishlist_id: wishlist.prefix_id, wished_item: { variant_id: 0, quantity: 1 } }expect(response).to have_http_status(:unprocessable_entity)expect(json_response['error']['code']).to eq('validation_error')@@ -58,7 +52,7 @@ RSpec.describe Spree::Api::V3::Store::WishlistItemsController, type: :controllerother_user = create(:user)other_wishlist = create(:wishlist, user: other_user, store: store)- post :create, params: { wishlist_id: other_wishlist.id, wished_item: { variant_id: new_variant.id, quantity: 1 } }+ post :create, params: { wishlist_id: other_wishlist.prefix_id, wished_item: { variant_id: new_variant.prefix_id, quantity: 1 } }expect(response).to have_http_status(:not_found)expect(json_response['error']['code']).to eq('record_not_found')@@ -66,7 +60,7 @@ RSpec.describe Spree::Api::V3::Store::WishlistItemsController, type: :controllerendit 'returns not found for non-existent wishlist' do- post :create, params: { wishlist_id: 0, wished_item: { variant_id: new_variant.id, quantity: 1 } }+ post :create, params: { wishlist_id: 0, wished_item: { variant_id: new_variant.prefix_id, quantity: 1 } }expect(response).to have_http_status(:not_found)expect(json_response['error']['code']).to eq('record_not_found')@@ -77,7 +71,7 @@ RSpec.describe Spree::Api::V3::Store::WishlistItemsController, type: :controllerbefore { request.headers['Authorization'] = nil }it 'returns unauthorized' do- post :create, params: { wishlist_id: wishlist.id, wished_item: { variant_id: new_variant.id, quantity: 1 } }+ post :create, params: { wishlist_id: wishlist.prefix_id, wished_item: { variant_id: new_variant.prefix_id, quantity: 1 } }expect(response).to have_http_status(:unauthorized)expect(json_response['error']['code']).to eq('authentication_required')@@ -88,7 +82,7 @@ RSpec.describe Spree::Api::V3::Store::WishlistItemsController, type: :controllerdescribe 'PATCH #update' doit 'updates wished item quantity' do- patch :update, params: { wishlist_id: wishlist.id, id: wished_item.id, wished_item: { quantity: 5 } }+ patch :update, params: { wishlist_id: wishlist.prefix_id, id: wished_item.prefix_id, wished_item: { quantity: 5 } }expect(response).to have_http_status(:ok)expect(wished_item.reload.quantity).to eq(5)@@ -96,7 +90,7 @@ RSpec.describe Spree::Api::V3::Store::WishlistItemsController, type: :controllercontext 'validation errors' doit 'returns errors for invalid quantity' do- patch :update, params: { wishlist_id: wishlist.id, id: wished_item.id, wished_item: { quantity: 0 } }+ patch :update, params: { wishlist_id: wishlist.prefix_id, id: wished_item.prefix_id, wished_item: { quantity: 0 } }expect(response).to have_http_status(:unprocessable_entity)expect(json_response['error']['code']).to eq('validation_error')@@ -106,7 +100,7 @@ RSpec.describe Spree::Api::V3::Store::WishlistItemsController, type: :controllercontext 'error handling' doit 'returns not found for non-existent item' do- patch :update, params: { wishlist_id: wishlist.id, id: 0, wished_item: { quantity: 5 } }+ patch :update, params: { wishlist_id: wishlist.prefix_id, id: 0, wished_item: { quantity: 5 } }expect(response).to have_http_status(:not_found)expect(json_response['error']['code']).to eq('record_not_found')@@ -118,7 +112,7 @@ RSpec.describe Spree::Api::V3::Store::WishlistItemsController, type: :controllerother_wishlist = create(:wishlist, user: other_user, store: store)other_item = create(:wished_item, wishlist: other_wishlist, variant: variant)- patch :update, params: { wishlist_id: other_wishlist.id, id: other_item.id, wished_item: { quantity: 5 } }+ patch :update, params: { wishlist_id: other_wishlist.prefix_id, id: other_item.prefix_id, wished_item: { quantity: 5 } }expect(response).to have_http_status(:not_found)expect(json_response['error']['code']).to eq('record_not_found')@@ -129,7 +123,7 @@ RSpec.describe Spree::Api::V3::Store::WishlistItemsController, type: :controllerdescribe 'DELETE #destroy' doit 'removes item from wishlist' doexpect {- delete :destroy, params: { wishlist_id: wishlist.id, id: wished_item.id }+ delete :destroy, params: { wishlist_id: wishlist.prefix_id, id: wished_item.prefix_id }}.to change(Spree::WishedItem, :count).by(-1)expect(response).to have_http_status(:no_content)@@ -137,7 +131,7 @@ RSpec.describe Spree::Api::V3::Store::WishlistItemsController, type: :controllercontext 'error handling' doit 'returns not found for non-existent item' do- delete :destroy, params: { wishlist_id: wishlist.id, id: 0 }+ delete :destroy, params: { wishlist_id: wishlist.prefix_id, id: 0 }expect(response).to have_http_status(:not_found)expect(json_response['error']['code']).to eq('record_not_found')@@ -149,7 +143,7 @@ RSpec.describe Spree::Api::V3::Store::WishlistItemsController, type: :controllerother_wishlist = create(:wishlist, user: other_user, store: store)other_item = create(:wished_item, wishlist: other_wishlist, variant: variant)- delete :destroy, params: { wishlist_id: other_wishlist.id, id: other_item.id }+ delete :destroy, params: { wishlist_id: other_wishlist.prefix_id, id: other_item.prefix_id }expect(response).to have_http_status(:not_found)expect(json_response['error']['code']).to eq('record_not_found')diff --git a/api/spec/controllers/spree/api/v3/store/wishlists_controller_spec.rb b/api/spec/controllers/spree/api/v3/store/wishlists_controller_spec.rbindex 6a0c09a331..5c39705d84 100644--- a/api/spec/controllers/spree/api/v3/store/wishlists_controller_spec.rb+++ b/api/spec/controllers/spree/api/v3/store/wishlists_controller_spec.rb@@ -18,7 +18,7 @@ RSpec.describe Spree::Api::V3::Store::WishlistsController, type: :controller doexpect(response).to have_http_status(:ok)expect(json_response['data'].size).to eq(1)- expect(json_response['data'].first['id']).to eq(wishlist.id)+ expect(json_response['data'].first['id']).to eq(wishlist.prefix_id)endit 'does not return other users wishlists' do@@ -28,7 +28,7 @@ RSpec.describe Spree::Api::V3::Store::WishlistsController, type: :controller doget :indexids = json_response['data'].map { |w| w['id'] }- expect(ids).not_to include(other_wishlist.id)+ expect(ids).not_to include(other_wishlist.prefix_id)endit 'returns pagination metadata' do@@ -52,10 +52,10 @@ RSpec.describe Spree::Api::V3::Store::WishlistsController, type: :controller dodescribe 'GET #show' doit 'returns the wishlist' do- get :show, params: { id: wishlist.id }+ get :show, params: { id: wishlist.prefix_id }expect(response).to have_http_status(:ok)- expect(json_response['id']).to eq(wishlist.id)+ expect(json_response['id']).to eq(wishlist.prefix_id)expect(json_response['name']).to eq(wishlist.name)end@@ -72,7 +72,7 @@ RSpec.describe Spree::Api::V3::Store::WishlistsController, type: :controller doother_user = create(:user)other_wishlist = create(:wishlist, user: other_user, store: store)- get :show, params: { id: other_wishlist.id }+ get :show, params: { id: other_wishlist.prefix_id }expect(response).to have_http_status(:not_found)expect(json_response['error']['code']).to eq('record_not_found')@@ -127,7 +127,7 @@ RSpec.describe Spree::Api::V3::Store::WishlistsController, type: :controller dodescribe 'PATCH #update' doit 'updates the wishlist name' do- patch :update, params: { id: wishlist.id, wishlist: { name: 'Updated Name' } }+ patch :update, params: { id: wishlist.prefix_id, wishlist: { name: 'Updated Name' } }expect(response).to have_http_status(:ok)expect(wishlist.reload.name).to eq('Updated Name')@@ -135,7 +135,7 @@ RSpec.describe Spree::Api::V3::Store::WishlistsController, type: :controller docontext 'validation errors' doit 'returns errors for blank name' do- patch :update, params: { id: wishlist.id, wishlist: { name: '' } }+ patch :update, params: { id: wishlist.prefix_id, wishlist: { name: '' } }expect(response).to have_http_status(:unprocessable_entity)expect(json_response['error']['code']).to eq('validation_error')@@ -148,7 +148,7 @@ RSpec.describe Spree::Api::V3::Store::WishlistsController, type: :controller doother_user = create(:user)other_wishlist = create(:wishlist, user: other_user, store: store)- patch :update, params: { id: other_wishlist.id, wishlist: { name: 'Hacked' } }+ patch :update, params: { id: other_wishlist.prefix_id, wishlist: { name: 'Hacked' } }expect(response).to have_http_status(:not_found)expect(json_response['error']['code']).to eq('record_not_found')@@ -159,7 +159,7 @@ RSpec.describe Spree::Api::V3::Store::WishlistsController, type: :controller dodescribe 'DELETE #destroy' doit 'deletes the wishlist' doexpect {- delete :destroy, params: { id: wishlist.id }+ delete :destroy, params: { id: wishlist.prefix_id }}.to change(Spree::Wishlist, :count).by(-1)expect(response).to have_http_status(:no_content)@@ -178,7 +178,7 @@ RSpec.describe Spree::Api::V3::Store::WishlistsController, type: :controller doother_user = create(:user)other_wishlist = create(:wishlist, user: other_user, store: store)- delete :destroy, params: { id: other_wishlist.id }+ delete :destroy, params: { id: other_wishlist.prefix_id }expect(response).to have_http_status(:not_found)expect(json_response['error']['code']).to eq('record_not_found')