1
0
mirror of https://github.com/django/django.git synced 2024-12-23 01:25:58 +00:00

Removed hardcoded docs version in csrf template.

This commit is contained in:
Ryan Hiebert 2024-05-18 04:30:12 -05:00 committed by Sarah Boyce
parent 0b33a3abc2
commit c201014e85
2 changed files with 13 additions and 1 deletions

View File

@ -53,7 +53,7 @@
<li>Your browser is accepting cookies.</li> <li>Your browser is accepting cookies.</li>
<li>The view function passes a <code>request</code> to the templates <a <li>The view function passes a <code>request</code> to the templates <a
href="https://docs.djangoproject.com/en/dev/topics/templates/#django.template.backends.base.Template.render"><code>render</code></a> href="https://docs.djangoproject.com/en/{{ docs_version }}/topics/templates/#django.template.backends.base.Template.render"><code>render</code></a>
method.</li> method.</li>
<li>In the template, there is a <code>{% templatetag openblock %} csrf_token <li>In the template, there is a <code>{% templatetag openblock %} csrf_token

View File

@ -132,3 +132,15 @@ class CsrfViewTests(SimpleTestCase):
with mock.patch.object(Path, "open") as m: with mock.patch.object(Path, "open") as m:
csrf_failure(mock.MagicMock(), mock.Mock()) csrf_failure(mock.MagicMock(), mock.Mock())
m.assert_called_once_with(encoding="utf-8") m.assert_called_once_with(encoding="utf-8")
@override_settings(DEBUG=True)
@mock.patch("django.views.csrf.get_docs_version", return_value="4.2")
def test_doc_links(self, mocked_get_complete_version):
response = self.client.post("/")
self.assertContains(response, "Forbidden", status_code=403)
self.assertNotContains(
response, "https://docs.djangoproject.com/en/dev/", status_code=403
)
self.assertContains(
response, "https://docs.djangoproject.com/en/4.2/", status_code=403
)