Refs #24944 -- Added test for overriding domain in email context in PasswordResetView.

This commit is contained in:
Mattia Procopio 2019-05-23 14:22:41 +02:00 committed by Mariusz Felisiak
parent 0670b1b403
commit aff61790a3
2 changed files with 5 additions and 1 deletions

View File

@ -134,6 +134,7 @@ class PasswordResetTest(AuthViewsTestCase):
self.assertEqual(response.status_code, 302) self.assertEqual(response.status_code, 302)
self.assertEqual(len(mail.outbox), 1) self.assertEqual(len(mail.outbox), 1)
self.assertIn('Email email context: "Hello!"', mail.outbox[0].body) self.assertIn('Email email context: "Hello!"', mail.outbox[0].body)
self.assertIn('http://custom.example.com/reset/', mail.outbox[0].body)
def test_html_mail_template(self): def test_html_mail_template(self):
""" """

View File

@ -91,7 +91,10 @@ urlpatterns = auth_urlpatterns + [
path('password_reset_from_email/', views.PasswordResetView.as_view(from_email='staffmember@example.com')), path('password_reset_from_email/', views.PasswordResetView.as_view(from_email='staffmember@example.com')),
path( path(
'password_reset_extra_email_context/', 'password_reset_extra_email_context/',
views.PasswordResetView.as_view(extra_email_context={'greeting': 'Hello!'})), views.PasswordResetView.as_view(
extra_email_context={'greeting': 'Hello!', 'domain': 'custom.example.com'},
),
),
path( path(
'password_reset/custom_redirect/', 'password_reset/custom_redirect/',
views.PasswordResetView.as_view(success_url='/custom/')), views.PasswordResetView.as_view(success_url='/custom/')),