1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-08-05 05:25:26 +02:00

feat: merge food into another (#1143)

* setup food repository

* add merge route and payloads

* remove type checking

* generate types

* implement merge dialog

* food repo tests

* split install from workflow

* bum dependencies

* revert changes

* update copy

* refactor URLs to avoid incorrect template being used

* stick advanced items under developer mode

* use utility component for advanced feature
This commit is contained in:
Hayden 2022-04-09 19:08:48 -08:00 committed by GitHub
parent 10784b6e24
commit b93dae109e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 319 additions and 175 deletions

View file

@ -0,0 +1,48 @@
from mealie.repos.repository_factory import AllRepositories
from mealie.schema.recipe.recipe import Recipe
from mealie.schema.recipe.recipe_ingredient import RecipeIngredient, SaveIngredientFood
from tests.utils.factories import random_string
from tests.utils.fixture_schemas import TestUser
def test_food_merger(database: AllRepositories, unique_user: TestUser):
slug1 = random_string(10)
food_1 = database.ingredient_foods.create(
SaveIngredientFood(
name=random_string(10),
group_id=unique_user.group_id,
)
)
food_2 = database.ingredient_foods.create(
SaveIngredientFood(
name=random_string(10),
group_id=unique_user.group_id,
)
)
recipe = database.recipes.create(
Recipe(
name=slug1,
user_id=unique_user.group_id,
group_id=unique_user.group_id,
recipe_ingredient=[
RecipeIngredient(note="", food=food_1), # type: ignore
RecipeIngredient(note="", food=food_2), # type: ignore
],
) # type: ignore
)
# Santiy check make sure recipe got created
assert recipe.id is not None
for ing in recipe.recipe_ingredient:
assert ing.food.id in [food_1.id, food_2.id] # type: ignore
database.ingredient_foods.merge(food_2.id, food_1.id)
recipe = database.recipes.get_one(recipe.slug)
for ingredient in recipe.recipe_ingredient:
assert ingredient.food.id == food_1.id # type: ignore