You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by gc...@apache.org on 2025/09/29 14:22:59 UTC

(allura) branch gc/8584 updated: fixup! fixup! [#8584] added missing validate function to formencode validators

This is an automated email from the ASF dual-hosted git repository.

gcruz pushed a commit to branch gc/8584
in repository https://gitbox.apache.org/repos/asf/allura.git


The following commit(s) were added to refs/heads/gc/8584 by this push:
     new 3a8151f90 fixup! fixup! [#8584] added missing validate function to formencode validators
3a8151f90 is described below

commit 3a8151f9074d72e780001ba6a854507ba29229c7
Author: Guillermo Cruz <gu...@slashdotmedia.com>
AuthorDate: Mon Sep 29 08:22:47 2025 -0600

    fixup! fixup! [#8584] added missing validate function to formencode validators
---
 Allura/allura/lib/widgets/forms.py                                    | 2 +-
 .../tests/unit/controllers/test_discussion_moderation_controller.py   | 4 ++--
 Allura/allura/tests/unit/patches.py                                   | 3 +++
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/Allura/allura/lib/widgets/forms.py b/Allura/allura/lib/widgets/forms.py
index 4ce3fa96b..032a7c69d 100644
--- a/Allura/allura/lib/widgets/forms.py
+++ b/Allura/allura/lib/widgets/forms.py
@@ -118,7 +118,7 @@ def display_field(self, field, ignore_errors=False):
         return display
 
     def validate(self, value, state=None):
-        state = tg.request if hasattr(tg, 'request') else state
+        state = getattr(tg, 'request', None)
         return super().validate(value, state)
 
 
diff --git a/Allura/allura/tests/unit/controllers/test_discussion_moderation_controller.py b/Allura/allura/tests/unit/controllers/test_discussion_moderation_controller.py
index 2b9a01fff..8faef962d 100644
--- a/Allura/allura/tests/unit/controllers/test_discussion_moderation_controller.py
+++ b/Allura/allura/tests/unit/controllers/test_discussion_moderation_controller.py
@@ -73,7 +73,7 @@ def get_post(self):
 
 
 class TestIndexWithNoPosts(WithDatabase):
-    patches = [patches.fake_app_patch]
+    patches = [patches.fake_app_patch, patches.fake_form_request_patch]
 
     def test_that_it_returns_no_posts(self):
         discussion = create_discussion()
@@ -82,7 +82,7 @@ def test_that_it_returns_no_posts(self):
 
 
 class TestIndexWithAPostInTheDiscussion(WithDatabase):
-    patches = [patches.fake_app_patch]
+    patches = [patches.fake_app_patch, patches.fake_form_request_patch]
 
     def setup_method(self, method):
         super().setup_method(method)
diff --git a/Allura/allura/tests/unit/patches.py b/Allura/allura/tests/unit/patches.py
index 630beeccf..ddb92ff00 100644
--- a/Allura/allura/tests/unit/patches.py
+++ b/Allura/allura/tests/unit/patches.py
@@ -17,6 +17,7 @@
 
 from mock import Mock, patch, MagicMock
 from tg import tmpl_context as c
+import tg
 
 from allura.tests.unit.factories import (
     create_project,
@@ -62,3 +63,5 @@ def fake_request_patch(test_case):
                  MagicMock(
                      referer='.'
                  ))
+def fake_form_request_patch(test_case):
+    return patch('tg.request', MagicMock(referer='.'))