From 617e36dc1ede2a311dfd03f18432b31cbfe4c0f7 Mon Sep 17 00:00:00 2001 From: levental Date: Mon, 19 Sep 2016 14:55:18 +0200 Subject: Fixed #20705 -- Allowed using PasswordResetForm with user models with an email field not named 'email'. --- tests/auth_tests/test_forms.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/auth_tests/test_forms.py') diff --git a/tests/auth_tests/test_forms.py b/tests/auth_tests/test_forms.py index c0e2961424..8d656bd6f9 100644 --- a/tests/auth_tests/test_forms.py +++ b/tests/auth_tests/test_forms.py @@ -26,6 +26,7 @@ from django.utils.translation import ugettext as _ from .models.custom_user import ( CustomUser, CustomUserWithoutIsActiveField, ExtensionUser, ) +from .models.with_custom_email_field import CustomEmailField from .models.with_integer_username import IntegerUsernameUser from .settings import AUTH_TEMPLATES @@ -812,6 +813,17 @@ class PasswordResetFormTest(TestDataMixin, TestCase): message.get_payload(1).get_payload() )) + @override_settings(AUTH_USER_MODEL='auth_tests.CustomEmailField') + def test_custom_email_field(self): + email = 'test@mail.com' + CustomEmailField.objects.create_user('test name', 'test password', email) + form = PasswordResetForm({'email': email}) + self.assertTrue(form.is_valid()) + form.save() + self.assertEqual(form.cleaned_data['email'], email) + self.assertEqual(len(mail.outbox), 1) + self.assertEqual(mail.outbox[0].to, [email]) + class ReadOnlyPasswordHashTest(SimpleTestCase): -- cgit v1.3