mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Fix api admin serializers
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user