You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by je...@apache.org on 2015/07/13 12:44:20 UTC
[16/29] allura git commit: [#7909] ticket:817 Use dashes when
suggesting project shortnames
[#7909] ticket:817 Use dashes when suggesting project shortnames
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/5b29187b
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/5b29187b
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/5b29187b
Branch: refs/heads/ib/7685
Commit: 5b29187b73d2934ba633ecc4f8e20766d234df58
Parents: 8376fe2
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Jul 8 13:21:55 2015 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Jul 9 21:20:52 2015 +0000
----------------------------------------------------------------------
Allura/allura/lib/plugin.py | 3 ++-
Allura/allura/tests/functional/test_neighborhood.py | 4 ++--
Allura/allura/tests/test_plugin.py | 5 ++++-
3 files changed, 8 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/5b29187b/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index 3fc5e87..be69b29 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -685,7 +685,8 @@ class ProjectRegistrationProvider(object):
Example: "My Great Project" -> "mygreatproject"
"""
- return re.sub("[^A-Za-z0-9]", "", project_name).lower()
+ name = re.sub("[^A-Za-z0-9]", " ", project_name).lower()
+ return '-'.join(name.split())
def rate_limit(self, user, neighborhood):
"""Check the various config-defined project registration rate
http://git-wip-us.apache.org/repos/asf/allura/blob/5b29187b/Allura/allura/tests/functional/test_neighborhood.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_neighborhood.py b/Allura/allura/tests/functional/test_neighborhood.py
index 593671d..5d0d3ac 100644
--- a/Allura/allura/tests/functional/test_neighborhood.py
+++ b/Allura/allura/tests/functional/test_neighborhood.py
@@ -825,9 +825,9 @@ class TestNeighborhood(TestController):
def test_name_suggest(self):
r = self.app.get('/p/suggest_name?project_name=My+Moz')
- assert_equal(r.json, dict(suggested_name='mymoz'))
+ assert_equal(r.json, dict(suggested_name='my-moz'))
r = self.app.get('/p/suggest_name?project_name=Te%st!')
- assert_equal(r.json, dict(suggested_name='test'))
+ assert_equal(r.json, dict(suggested_name='te-st'))
def test_name_check(self):
for name in ('My+Moz', 'Te%st!', 'ab', 'a' * 16):
http://git-wip-us.apache.org/repos/asf/allura/blob/5b29187b/Allura/allura/tests/test_plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_plugin.py b/Allura/allura/tests/test_plugin.py
index 64b9695..2b8b039 100644
--- a/Allura/allura/tests/test_plugin.py
+++ b/Allura/allura/tests/test_plugin.py
@@ -67,8 +67,11 @@ class TestProjectRegistrationProvider(object):
def test_suggest_name(self):
f = self.provider.suggest_name
+ assert_equals(f('Foo Bar', Mock()), 'foo-bar')
assert_equals(f('A More Than Fifteen Character Name', Mock()),
- 'amorethanfifteencharactername')
+ 'a-more-than-fifteen-character-name')
+ assert_equals(f('foo! bar?.. the great!!', Mock()),
+ 'foo-bar-the-great')
@patch('allura.model.Project')
def test_shortname_validator(self, Project):