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