mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Export variant's display_name if present
The `#name` method is simply delegated to a variant's product.
This commit is contained in:
@@ -22,8 +22,10 @@ class DfcBuilder
|
||||
)
|
||||
|
||||
DataFoodConsortium::Connector::SuppliedProduct.new(
|
||||
id, name: variant.name, description: variant.description,
|
||||
quantity: QuantitativeValueBuilder.quantity(variant),
|
||||
id,
|
||||
name: variant.name_to_display,
|
||||
description: variant.description,
|
||||
quantity: QuantitativeValueBuilder.quantity(variant),
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
@@ -22,5 +22,20 @@ describe DfcBuilder do
|
||||
expect(product.quantity.value).to eq 1.0
|
||||
expect(product.quantity.unit.semanticId).to eq "dfc-m:Gram"
|
||||
end
|
||||
|
||||
it "assigns the product name by default" do
|
||||
variant.product.name = "Apple"
|
||||
product = DfcBuilder.supplied_product(variant)
|
||||
|
||||
expect(product.name).to eq "Apple"
|
||||
end
|
||||
|
||||
it "assigns the variant name if present" do
|
||||
variant.product.name = "Apple"
|
||||
variant.display_name = "Granny Smith"
|
||||
product = DfcBuilder.supplied_product(variant)
|
||||
|
||||
expect(product.name).to eq "Granny Smith"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user