diff options
Diffstat (limited to 'pydis_site/apps')
| -rw-r--r-- | pydis_site/apps/redirect/redirects.yaml | 8 | ||||
| -rw-r--r-- | pydis_site/apps/redirect/tests.py | 16 | 
2 files changed, 22 insertions, 2 deletions
| diff --git a/pydis_site/apps/redirect/redirects.yaml b/pydis_site/apps/redirect/redirects.yaml index 546e24ae..caaab1f1 100644 --- a/pydis_site/apps/redirect/redirects.yaml +++ b/pydis_site/apps/redirect/redirects.yaml @@ -51,3 +51,11 @@ events_code_jams_seven_redirect:    original_path: pages/code-jams/code-jam-7/    redirect_route: "events:page"    redirect_arguments: ["code-jams/7"] + +# Guides +# Prefix redirects +guides_pydis_guides_contributing_prefix_redirect: +  original_path: pages/contributing/<path:path>/  # path:path will be joined together with static arguments. +  redirect_route: "content:page_category" +  redirect_arguments: ["guides/pydis-guides/contributing/"]  # It is important to put / at end in prefix redirect! +  prefix_redirect: true diff --git a/pydis_site/apps/redirect/tests.py b/pydis_site/apps/redirect/tests.py index ac60d1c8..0738a143 100644 --- a/pydis_site/apps/redirect/tests.py +++ b/pydis_site/apps/redirect/tests.py @@ -3,7 +3,10 @@ from django.conf import settings  from django.test import TestCase  from django.urls import reverse -TESTING_ARGUMENTS = {"resources_resources_redirect": ("reading",)} +TESTING_ARGUMENTS = { +    "resources_resources_redirect": ("reading",), +    "guides_pydis_guides_contributing_prefix_redirect": ("sir-lancebot/env-var-reference",), +}  class RedirectTests(TestCase): @@ -33,12 +36,21 @@ class RedirectTests(TestCase):                      follow=True                  ) +                if data.get("prefix_redirect", False): +                    expected_args = ( +                        "".join( +                            tuple(data.get("redirect_arguments", ())) + TESTING_ARGUMENTS.get(name, ()) +                        ), +                    ) +                else: +                    expected_args = TESTING_ARGUMENTS.get(name, ()) + tuple(data.get("redirect_arguments", ())) +                  self.assertEqual(1, len(resp.redirect_chain))                  self.assertRedirects(                      resp,                      reverse(                          f"home:{data['redirect_route']}", -                        args=TESTING_ARGUMENTS.get(name, ()) + tuple(data.get("redirect_arguments", ())) +                        args=expected_args                      ),                      status_code=301                  ) | 
