Skip to content

Commit 6e15a2b

Browse files
authored
Redirects: test redirects with projects prefix (#10179)
This is only available in the new implementation. Closes #7552
1 parent 8f6c990 commit 6e15a2b

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

readthedocs/proxito/tests/test_old_redirects.py

+37
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,43 @@ def setUp(self):
673673
future_default_true=True,
674674
)
675675

676+
def test_redirect_using_projects_prefix(self):
677+
"""
678+
Test that we can support redirects using the ``/projects/`` prefix.
679+
680+
https://github.com/readthedocs/readthedocs.org/issues/7552
681+
"""
682+
redirect = fixture.get(
683+
Redirect,
684+
project=self.project,
685+
redirect_type="exact",
686+
from_url="/projects/$rest",
687+
to_url="https://example.com/projects/",
688+
)
689+
self.assertEqual(self.project.redirects.count(), 1)
690+
r = self.client.get(
691+
"/projects/deleted-subproject/en/latest/guides/install.html",
692+
HTTP_HOST="project.dev.readthedocs.io",
693+
)
694+
self.assertEqual(r.status_code, 302)
695+
self.assertEqual(
696+
r["Location"],
697+
"https://example.com/projects/deleted-subproject/en/latest/guides/install.html",
698+
)
699+
700+
redirect.from_url = "/projects/not-found/$rest"
701+
redirect.to_url = "/projects/subproject/"
702+
redirect.save()
703+
r = self.client.get(
704+
"/projects/not-found/en/latest/guides/install.html",
705+
HTTP_HOST="project.dev.readthedocs.io",
706+
)
707+
self.assertEqual(r.status_code, 302)
708+
self.assertEqual(
709+
r["Location"],
710+
"http://project.dev.readthedocs.io/projects/subproject/en/latest/guides/install.html",
711+
)
712+
676713

677714
@override_settings(PUBLIC_DOMAIN="dev.readthedocs.io")
678715
class UserForcedRedirectTests(BaseDocServing):

0 commit comments

Comments
 (0)