mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Add spec for SuppliedProduct serializer
This commit is contained in:
@@ -18,7 +18,7 @@ module DfcProvider
|
||||
def id
|
||||
dfc_provider_routes.api_dfc_provider_enterprise_url(
|
||||
id: object.id,
|
||||
host: root_url
|
||||
host: host
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ module DfcProvider
|
||||
def id
|
||||
dfc_provider_routes.api_dfc_provider_person_url(
|
||||
id: object.id,
|
||||
host: root_url
|
||||
host: host
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ module DfcProvider
|
||||
dfc_provider_routes.api_dfc_provider_enterprise_supplied_product_url(
|
||||
enterprise_id: object.product.supplier_id,
|
||||
id: object.id,
|
||||
host: root_url
|
||||
host: host
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe DfcProvider::SuppliedProductSerializer do
|
||||
let!(:product) { create(:simple_product ) }
|
||||
let!(:variant) { product.variants.first }
|
||||
|
||||
subject { described_class.new(variant) }
|
||||
|
||||
describe '#id' do
|
||||
it 'returns the expected value' do
|
||||
expect(subject.id).to eq(
|
||||
DfcProvider::Engine.routes.url_helpers.api_dfc_provider_enterprise_supplied_product_url(
|
||||
enterprise_id: product.supplier_id,
|
||||
id: variant.id,
|
||||
host: 'http://test.host'
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#unit' do
|
||||
it 'returns the rdfs label value' do
|
||||
expect(subject.unit).to eq(
|
||||
{
|
||||
'@id' => '/unit/piece',
|
||||
'rdfs:label' => 'piece'
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user