mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-08-05 13:35:23 +02:00
feat: Improve Public URL Readability (#2482)
* added support for group slugs * modified frontend to use links with group slug * fixed test refs * unused import --------- Co-authored-by: Hayden <64056131+hay-kot@users.noreply.github.com>
This commit is contained in:
parent
99372aa2b6
commit
095edef95e
12 changed files with 166 additions and 18 deletions
|
@ -34,6 +34,8 @@ def test_public_recipe_success(
|
|||
test_case: PublicRecipeTestCase,
|
||||
):
|
||||
group = database.groups.get_one(unique_user.group_id)
|
||||
assert group
|
||||
|
||||
group.preferences.private_group = test_case.private_group
|
||||
database.group_preferences.update(group.id, group.preferences)
|
||||
|
||||
|
@ -42,9 +44,10 @@ def test_public_recipe_success(
|
|||
database.recipes.update(random_recipe.slug, random_recipe)
|
||||
|
||||
# Try to access recipe
|
||||
recipe_group = database.groups.get_by_slug_or_id(random_recipe.group_id)
|
||||
response = api_client.get(
|
||||
api_routes.explore_recipes_group_id_recipe_slug(
|
||||
random_recipe.group_id,
|
||||
api_routes.explore_recipes_group_slug_recipe_slug(
|
||||
recipe_group.slug,
|
||||
random_recipe.slug,
|
||||
)
|
||||
)
|
||||
|
|
24
tests/unit_tests/repository_tests/test_group_repository.py
Normal file
24
tests/unit_tests/repository_tests/test_group_repository.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
from mealie.repos.repository_factory import AllRepositories
|
||||
from tests.utils.factories import random_int, random_string
|
||||
|
||||
|
||||
def test_group_resolve_similar_names(database: AllRepositories):
|
||||
base_group_name = random_string()
|
||||
groups = database.groups.create_many({"name": base_group_name} for _ in range(random_int(3, 10)))
|
||||
|
||||
seen_names = set()
|
||||
seen_slugs = set()
|
||||
for group in groups:
|
||||
assert group.name not in seen_names
|
||||
assert group.slug not in seen_slugs
|
||||
seen_names.add(group.name)
|
||||
seen_slugs.add(group.slug)
|
||||
|
||||
assert base_group_name in group.name
|
||||
|
||||
|
||||
def test_group_get_by_slug_or_id(database: AllRepositories):
|
||||
groups = [database.groups.create({"name": random_string()}) for _ in range(random_int(3, 10))]
|
||||
for group in groups:
|
||||
assert database.groups.get_by_slug_or_id(group.id) == group
|
||||
assert database.groups.get_by_slug_or_id(group.slug) == group
|
|
@ -225,9 +225,9 @@ def comments_item_id(item_id):
|
|||
return f"{prefix}/comments/{item_id}"
|
||||
|
||||
|
||||
def explore_recipes_group_id_recipe_slug(group_id, recipe_slug):
|
||||
"""`/api/explore/recipes/{group_id}/{recipe_slug}`"""
|
||||
return f"{prefix}/explore/recipes/{group_id}/{recipe_slug}"
|
||||
def explore_recipes_group_slug_recipe_slug(group_slug, recipe_slug):
|
||||
"""`/api/explore/recipes/{group_slug}/{recipe_slug}`"""
|
||||
return f"{prefix}/explore/recipes/{group_slug}/{recipe_slug}"
|
||||
|
||||
|
||||
def foods_item_id(item_id):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue