From 53e7b024716b0174eeeeedc78d00279d57bf9f35 Mon Sep 17 00:00:00 2001 From: Gaetan Craig-Riou Date: Tue, 5 Mar 2024 20:33:36 +1100 Subject: [PATCH] Fix admin api exchange products controller --- .../api/admin/for_order_cycle/supplied_product_serializer.rb | 2 +- spec/controllers/api/v0/exchange_products_controller_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/serializers/api/admin/for_order_cycle/supplied_product_serializer.rb b/app/serializers/api/admin/for_order_cycle/supplied_product_serializer.rb index f135d31dab..7e22751b72 100644 --- a/app/serializers/api/admin/for_order_cycle/supplied_product_serializer.rb +++ b/app/serializers/api/admin/for_order_cycle/supplied_product_serializer.rb @@ -7,7 +7,7 @@ module Api attributes :name, :supplier_name, :image_url, :variants def supplier_name - object.supplier&.name + object.variants.first.supplier&.name end def image_url diff --git a/spec/controllers/api/v0/exchange_products_controller_spec.rb b/spec/controllers/api/v0/exchange_products_controller_spec.rb index ea226a80f1..f290186450 100644 --- a/spec/controllers/api/v0/exchange_products_controller_spec.rb +++ b/spec/controllers/api/v0/exchange_products_controller_spec.rb @@ -39,7 +39,7 @@ module Api api_get :index, exchange_id: exchange.id, order_cycle_id: 666, enterprise_id: 666, incoming: false expect(json_response["products"].first["supplier_name"]) - .to eq exchange.variants.first.product.supplier.name + .to eq exchange.variants.first.supplier.name end end @@ -48,7 +48,7 @@ module Api api_get :index, order_cycle_id: order_cycle.id, enterprise_id: exchange.sender_id, incoming: true expect(json_response["products"].first["supplier_name"]) - .to eq exchange.variants.first.product.supplier.name + .to eq exchange.variants.first.supplier.name end end end