You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2013/05/24 20:18:19 UTC

[43/50] git commit: [#4740] ticket:331 Test ticket form preserves custom fields values

[#4740] ticket:331 Test ticket form preserves custom fields values


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

Branch: refs/heads/db/6007
Commit: 6686bcfd00a4d3a69e65173467ef048206be95ca
Parents: 257f839
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu May 23 11:55:49 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Fri May 24 13:09:19 2013 +0000

----------------------------------------------------------------------
 .../forgetracker/tests/functional/test_root.py     |   33 +++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6686bcfd/ForgeTracker/forgetracker/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tests/functional/test_root.py b/ForgeTracker/forgetracker/tests/functional/test_root.py
index a77e9c6..84b63e5 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -830,6 +830,39 @@ class TestFunctionalController(TrackerTestController):
         response = self.app.get('/p/test/bugs/search/')
         assert 'Edit All' not in response
 
+    def test_custom_fields_preserve_user_input_on_form_errors(self):
+        params = dict(
+            custom_fields=[
+                dict(name='_priority', label='Priority', type='select',
+                     options='normal urgent critical'),
+                dict(name='_category', label='Category', type='string',
+                     options='')],
+            open_status_names='aa bb',
+            closed_status_names='cc',
+            )
+        self.app.post(
+            '/admin/bugs/set_custom_fields', params=variable_encode(params))
+        # Test new ticket form
+        r = self.app.get('/bugs/new/')
+        form = r.forms[1]
+        form['ticket_form.custom_fields._priority'] = 'urgent'
+        form['ticket_form.custom_fields._category'] = 'bugs'
+        error_form = form.submit()
+        assert_equal(error_form.forms[1]['ticket_form.custom_fields._priority'].value, 'urgent')
+        assert_equal(error_form.forms[1]['ticket_form.custom_fields._category'].value, 'bugs')
+        # Test edit ticket form
+        self.new_ticket(summary='Test ticket')
+        response = self.app.get('/bugs/1/')
+        form = response.forms[1]
+        assert_equal(form['ticket_form.custom_fields._priority'].value, 'normal')
+        assert_equal(form['ticket_form.custom_fields._category'].value, '')
+        form['ticket_form.summary'] = ''
+        form['ticket_form.custom_fields._priority'] = 'urgent'
+        form['ticket_form.custom_fields._category'] = 'bugs'
+        error_form = form.submit()
+        assert_equal(error_form.forms[1]['ticket_form.custom_fields._priority'].value, 'urgent')
+        assert_equal(error_form.forms[1]['ticket_form.custom_fields._category'].value, 'bugs')
+
     def test_new_ticket_validation(self):
         summary = 'ticket summary'
         response = self.app.get('/bugs/new/')