You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2013/04/12 19:08:59 UTC
[4/4] git commit: [#4504] Fixed $USER search for *anonymous
[#4504] Fixed $USER search for *anonymous
Signed-off-by: Cory Johns <cj...@slashdotmedia.com>
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/96479410
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/96479410
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/96479410
Branch: refs/heads/master
Commit: 964794109250beb17c0780b9cc2155c41783699f
Parents: f785c52
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Fri Apr 12 17:08:17 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Fri Apr 12 17:08:17 2013 +0000
----------------------------------------------------------------------
Allura/allura/lib/search.py | 2 +-
Allura/allura/tests/test_helpers.py | 7 +++++--
2 files changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/96479410/Allura/allura/lib/search.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/search.py b/Allura/allura/lib/search.py
index 89d1d6e..b4bbd2f 100644
--- a/Allura/allura/lib/search.py
+++ b/Allura/allura/lib/search.py
@@ -26,7 +26,7 @@ def inject_user(q, user=None):
'''Replace $USER with current user's name.'''
if user is None:
user = c.user
- return q.replace('$USER', user.username) if q else q
+ return q.replace('$USER', '"%s"' % user.username) if q else q
def search(q,short_timeout=False,ignore_errors=True,**kw):
q = inject_user(q)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/96479410/Allura/allura/tests/test_helpers.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_helpers.py b/Allura/allura/tests/test_helpers.py
index 8a7065f..ed919b0 100644
--- a/Allura/allura/tests/test_helpers.py
+++ b/Allura/allura/tests/test_helpers.py
@@ -194,7 +194,10 @@ def test_inject_user(context):
assert_equals(inject_user('', user), '')
assert_equals(inject_user('query', user), 'query')
result = inject_user('reported_by_s:$USER OR assigned_to_s:$USER', user)
- assert_equals(result, 'reported_by_s:user01 OR assigned_to_s:user01')
+ assert_equals(result, 'reported_by_s:"user01" OR assigned_to_s:"user01"')
context.user = Mock(username='admin1')
result = inject_user('reported_by_s:$USER OR assigned_to_s:$USER')
- assert_equals(result, 'reported_by_s:admin1 OR assigned_to_s:admin1')
+ assert_equals(result, 'reported_by_s:"admin1" OR assigned_to_s:"admin1"')
+ context.user = Mock(username='*anonymous')
+ result = inject_user('reported_by_s:$USER OR assigned_to_s:$USER')
+ assert_equals(result, 'reported_by_s:"*anonymous" OR assigned_to_s:"*anonymous"')