From 40f40038f84602a8461b1f4d2e98fbb8883feaae Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Fri, 5 May 2023 22:51:35 +0200 Subject: [PATCH] Fix url order for retrieving user stars Since that initial PR, the username regex has been more gready. --- umap/tests/test_map_views.py | 12 ++++++++++++ umap/urls.py | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/umap/tests/test_map_views.py b/umap/tests/test_map_views.py index 5266f0cd..7a8f2f49 100644 --- a/umap/tests/test_map_views.py +++ b/umap/tests/test_map_views.py @@ -557,3 +557,15 @@ def test_anonymous_cannot_star_map(client, map): assert response.status_code == 302 assert "login" in response["Location"] assert Star.objects.count() == 0 + + +def test_user_can_see_their_star(client, map, user): + url = reverse('map_star', args=(map.pk,)) + client.login(username=user.username, password="123123") + assert Star.objects.filter(by=user).count() == 0 + response = client.post(url) + assert response.status_code == 200 + url = reverse('user_stars', args=(user.username,)) + response = client.get(url) + assert response.status_code == 200 + assert map.name in response.content.decode() diff --git a/umap/urls.py b/umap/urls.py index 58beb6a4..1c35bdb7 100644 --- a/umap/urls.py +++ b/umap/urls.py @@ -151,8 +151,8 @@ urlpatterns += i18n_patterns( ), re_path(r"^search/$", views.search, name="search"), re_path(r"^about/$", views.about, name="about"), + re_path(r"^user/(?P.+)/stars/$", views.user_stars, name='user_stars'), re_path(r"^user/(?P.+)/$", views.user_maps, name="user_maps"), - re_path(r'^user/(?P[-_\w@]+)/stars/$', views.user_stars, name='user_stars'), re_path(r"", include(i18n_urls)), )