Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow serving size to be hyphenated #11161

Merged
merged 1 commit into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/ProductOpener/DataQualityFood.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,7 @@ sub check_nutrition_data ($product_ref) {
# catch serving_size = "serving", regardless of setting (per 100g or per serving)
if ( (defined $product_ref->{serving_size})
and ($product_ref->{serving_size} ne "")
and ($product_ref->{serving_size} ne "-")
and ($product_ref->{serving_size} !~ /\d/))
{
push @{$product_ref->{data_quality_errors_tags}}, "en:serving-size-is-missing-digits";
Expand Down
18 changes: 16 additions & 2 deletions tests/unit/dataqualityfood.t
Original file line number Diff line number Diff line change
Expand Up @@ -569,14 +569,28 @@ ProductOpener::DataQuality::check_quality($product_ref);
check_quality_and_test_product_has_quality_tag(
$product_ref,
'en:serving-size-is-missing-digits',
'serving size should contains digits', 1
'serving size does not contain digits', 1
);
$product_ref = {serving_size => "120g"};
ProductOpener::DataQuality::check_quality($product_ref);
check_quality_and_test_product_has_quality_tag(
$product_ref,
'en:serving-size-is-missing-digits',
'serving size should contains digits', 0
'serving size contains digits', 0
);
$product_ref = {serving_size => ""};
ProductOpener::DataQuality::check_quality($product_ref);
check_quality_and_test_product_has_quality_tag(
$product_ref,
'en:serving-size-is-missing-digits',
'serving size is empty', 0
);
$product_ref = {serving_size => "-"};
ProductOpener::DataQuality::check_quality($product_ref);
check_quality_and_test_product_has_quality_tag(
$product_ref,
'en:serving-size-is-missing-digits',
'serving size is -', 0
);

# serving size is missing
Expand Down
Loading