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/08 15:29:47 UTC

allura git commit: [#7909] ticket:817 Use dashes when suggesting project shortnames

Repository: allura
Updated Branches:
  refs/heads/ib/7909 [created] b7cb76137


[#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/b7cb7613
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/b7cb7613
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/b7cb7613

Branch: refs/heads/ib/7909
Commit: b7cb76137395b62e9c4ef5d6579f5a7b472f92bc
Parents: 93a1ecc
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Jul 8 13:21:55 2015 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Jul 8 13:56:29 2015 +0300

----------------------------------------------------------------------
 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/b7cb7613/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/b7cb7613/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/b7cb7613/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):