Fixed #9881: Added the to the login view context, not just the site's name. Thanks, nessita.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@10330 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jacob Kaplan-Moss 2009-04-01 16:37:48 +00:00
parent e6ad4fb901
commit 19b9211a3b
3 changed files with 26 additions and 1 deletions

View File

@ -1,6 +1,6 @@
from django.contrib.auth.tests.basic import BASIC_TESTS
from django.contrib.auth.tests.views \
import PasswordResetTest, ChangePasswordTest
import PasswordResetTest, ChangePasswordTest, LoginTest
from django.contrib.auth.tests.forms import FORM_TESTS
from django.contrib.auth.tests.remote_user \
import RemoteUserTest, RemoteUserNoCreateTest, RemoteUserCustomTest
@ -14,4 +14,5 @@ __test__ = {
'FORM_TESTS': FORM_TESTS,
'TOKEN_GENERATOR_TESTS': TOKEN_GENERATOR_TESTS,
'CHANGEPASSWORD_TESTS': ChangePasswordTest,
'LOGIN_TESTS': LoginTest,
}

View File

@ -3,9 +3,12 @@ import os
import re
from django.conf import settings
from django.contrib.auth.forms import AuthenticationForm
from django.contrib.sites.models import Site, RequestSite
from django.contrib.auth.models import User
from django.test import TestCase
from django.core import mail
from django.core.urlresolvers import reverse
class PasswordResetTest(TestCase):
fixtures = ['authtestdata.json']
@ -162,3 +165,23 @@ class ChangePasswordTest(TestCase):
self.fail_login()
self.login(password='password1')
class LoginTest(TestCase):
fixtures = ['authtestdata.json']
urls = 'django.contrib.auth.urls'
def setUp(self):
self.old_TEMPLATE_DIRS = settings.TEMPLATE_DIRS
settings.TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__), 'templates'),)
def tearDown(self):
settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS
def test_current_site_in_context_after_login(self):
response = self.client.get(reverse('django.contrib.auth.views.login'))
self.assertEquals(response.status_code, 200)
site = Site.objects.get_current()
self.assertEquals(response.context['site'], site)
self.assertEquals(response.context['site_name'], site.name)
self.assert_(isinstance(response.context['form'], AuthenticationForm),
'Login form is not an AuthenticationForm')

View File

@ -38,6 +38,7 @@ def login(request, template_name='registration/login.html', redirect_field_name=
return render_to_response(template_name, {
'form': form,
redirect_field_name: redirect_to,
'site': current_site,
'site_name': current_site.name,
}, context_instance=RequestContext(request))
login = never_cache(login)