Show new users an error page when they try to sign up for a deactivated realm.

(imported from commit 1696a6a5d26ec92b881cd3fda43e6b262e2fbfa5)
This commit is contained in:
Jessica McKellar
2014-01-07 13:04:26 -05:00
parent 511e1a12e3
commit 32549ec135
3 changed files with 36 additions and 0 deletions

View File

@@ -811,6 +811,21 @@ class LoginTest(AuthedTestCase):
user_profile = get_user_profile_by_email('test@zulip.com')
self.assertEqual(self.client.session['_auth_user_id'], user_profile.id)
def test_register_deactivated(self):
"""
If you try to register for a deactivated realm, you get a clear error
page.
"""
realm = Realm.objects.get(domain="zulip.com")
realm.deactivated = True
realm.save(update_fields=["deactivated"])
result = self.register("test", "test")
self.assertIn("has been deactivated", result.content.replace("\n", " "))
with self.assertRaises(UserProfile.DoesNotExist):
get_user_profile_by_email('test@zulip.com')
def test_logout(self):
self.login("hamlet@zulip.com")
self.client.post('/accounts/logout/')