Fix api admin serializers

This commit is contained in:
Gaetan Craig-Riou
2024-03-13 16:30:31 +11:00
parent e1c3f0a31c
commit 507fa028c1
3 changed files with 3 additions and 4 deletions

View File

@@ -7,8 +7,6 @@ module Api
:inherits_properties, :on_hand, :price, :import_date, :image_url,
:thumb_url, :variants
has_one :supplier, key: :producer_id, embed: :id
def variants
ActiveModel::ArraySerializer.new(
object.variants,

View File

@@ -9,6 +9,7 @@ module Api
:price, :on_demand, :on_hand, :in_stock, :stock_location_id, :stock_location_name
has_one :primary_taxon, key: :category_id, embed: :id
has_one :supplier, key: :producer_id, embed: :id
def name
if object.full_name.present?
@@ -31,7 +32,7 @@ module Api
end
def producer_name
object.product.supplier.name
object.supplier.name
end
def image

View File

@@ -3,7 +3,7 @@
require 'spec_helper'
RSpec.describe Api::Admin::ProductSerializer do
let(:product) { create(:simple_product) }
let(:product) { create(:simple_product, supplier_id: create(:supplier_enterprise).id) }
let(:serializer) { described_class.new(product) }
it "serializes a product" do