allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jetm...@apache.org
Subject [28/35] git commit: [#7657] ticket:651 Add test form admin page email changes
Date Wed, 17 Sep 2014 13:34:15 GMT
[#7657] ticket:651 Add test form admin page email changes


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/2d18821f
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/2d18821f
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/2d18821f

Branch: refs/heads/je/42cc_7657
Commit: 2d18821fff597fdc37ea905fb2618ad6ae560047
Parents: 5927a21
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Tue Sep 16 17:07:23 2014 +0300
Committer: Igor Bondarenko <jetmind2@gmail.com>
Committed: Wed Sep 17 16:11:38 2014 +0300

----------------------------------------------------------------------
 .../allura/tests/functional/test_site_admin.py  | 58 ++++++++++++++++++++
 1 file changed, 58 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/2d18821f/Allura/allura/tests/functional/test_site_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_site_admin.py b/Allura/allura/tests/functional/test_site_admin.py
index ce7e47e..eea2be4 100644
--- a/Allura/allura/tests/functional/test_site_admin.py
+++ b/Allura/allura/tests/functional/test_site_admin.py
@@ -28,6 +28,7 @@ from bson import ObjectId
 
 from allura import model as M
 from allura.tests import TestController
+from allura.tests import decorators as td
 from allura.lib import helpers as h
 from allura.lib.decorators import task
 
@@ -318,6 +319,63 @@ class TestUserDetails(TestController):
         assert_in(u'User enabled', self.webflash(r))
         assert_equal(M.User.by_username('test-user').disabled, False)
 
+    def test_emails(self):
+        # add test@example.com
+        with td.audits('New email address: test@example.com', user=True):
+            r = self.app.post('/nf/admin/user/update_emails', params={
+                'username': 'test-user',
+                'new_addr.addr': 'test@example.com',
+                'new_addr.claim': 'Claim Address',
+                'primary_addr': 'test@example.com'},
+                extra_environ=dict(username='test-admin'))
+        r = self.app.get('/nf/admin/user/test-user')
+        assert_in('test@example.com', r)
+        em = M.EmailAddress.query.get(email='test@example.com')
+        assert_equal(em.confirmed, True)
+        user = M.User.query.get(username='test-user')
+        assert_equal(user.get_pref('email_address'), 'test@example.com')
+
+        # add test2@example.com
+        with td.audits('New email address: test2@example.com', user=True):
+            r = self.app.post('/nf/admin/user/update_emails', params={
+                'username': 'test-user',
+                'new_addr.addr': 'test2@example.com',
+                'new_addr.claim': 'Claim Address',
+                'primary_addr': 'test@example.com'},
+                extra_environ=dict(username='test-admin'))
+        r = self.app.get('/nf/admin/user/test-user')
+        assert_in('test2@example.com', r)
+        em = M.EmailAddress.query.get(email='test2@example.com')
+        assert_equal(em.confirmed, True)
+        user = M.User.query.get(username='test-user')
+        assert_equal(user.get_pref('email_address'), 'test@example.com')
+
+        # change primary: test -> test2
+        with td.audits('Primary email changed: test@example.com => test2@example.com',
user=True):
+            r = self.app.post('/nf/admin/user/update_emails', params={
+                'username': 'test-user',
+                'new_addr.addr': '',
+                'primary_addr': 'test2@example.com'},
+                extra_environ=dict(username='test-admin'))
+        r = self.app.get('/nf/admin/user/test-user')
+        user = M.User.query.get(username='test-user')
+        assert_equal(user.get_pref('email_address'), 'test2@example.com')
+
+        # remove test2@example.com
+        with td.audits('Email address deleted: test2@example.com', user=True):
+            r = self.app.post('/nf/admin/user/update_emails', params={
+                'username': 'test-user',
+                'addr-1.ord': '1',
+                'addr-2.ord': '2',
+                'addr-2.delete': 'on',
+                'new_addr.addr': '',
+                'primary_addr': 'test2@example.com'},
+                extra_environ=dict(username='test-admin'))
+        r = self.app.get('/nf/admin/user/test-user')
+        user = M.User.query.get(username='test-user')
+        # test@example.com set as primary since test2@example.com is deleted
+        assert_equal(user.get_pref('email_address'), 'test@example.com')
+
 
 @task
 def test_task(*args, **kw):


Mime
View raw message