Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
Fix and test for #3722
Browse files Browse the repository at this point in the history
  • Loading branch information
kaguillera committed Jul 21, 2016
1 parent 223679a commit 868b876
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions gratipay/models/community.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
from postgres.orm import Model


name_pattern = re.compile(r'^[A-Za-z0-9,._ -]+$')
name_pattern = re.compile(r"^[A-Za-z0-9,._ '-]+$")

def slugize(slug):
"""Convert a string to a string for an URL.
"""
assert name_pattern.match(slug) is not None
slug = slug.lower()
for c in (' ', ',', '.', '_'):
for c in (' ', ',', '.', '_','\''):
slug = slug.replace(c, '-')
while '--' in slug:
slug = slug.replace('--', '-')
Expand Down
8 changes: 7 additions & 1 deletion tests/py/test_fake_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from gratipay.utils import fake_data
from gratipay.testing import Harness

from gratipay.models import community

class TestFakeData(Harness):
"""
Expand Down Expand Up @@ -34,3 +34,9 @@ def test_fake_participant_identity(self):
crusher = self.make_participant('crusher', email_address='[email protected]')
country_id = fake_data.fake_participant_identity(crusher)
assert [x.country.id for x in crusher.list_identity_metadata()] == [country_id]

def test_slugize(self):
"""
Just a test to ensure that slugize can handle single quotes
"""
assert community.slugize("D'Amorebury") == "d-amorebury"

0 comments on commit 868b876

Please sign in to comment.