allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [17/27] git commit: [#7657] ticket:651 Add test form admin page email changes
Date Mon, 29 Sep 2014 16:17:48 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/c28cf1fa
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/c28cf1fa
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/c28cf1fa

Branch: refs/heads/db/7657
Commit: c28cf1fadedea510536c582335c51289172bbd84
Parents: 8e583ea
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Tue Sep 16 17:07:23 2014 +0300
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Fri Sep 26 18:30:43 2014 +0000

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


http://git-wip-us.apache.org/repos/asf/allura/blob/c28cf1fa/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 02436eb..2dcfc18 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
 
@@ -413,6 +414,64 @@ 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):
     """test_task doc string"""


Mime
View raw message