Browse Source

Fix: Search path supports queries with all non-whitespace characters. (#53)

issue54
Drew Larson 8 years ago
committed by GitHub
parent
commit
5d840ac0a4
  1. 17
      bikeshop_project/registration/tests/test_views.py
  2. 2
      bikeshop_project/registration/urls.py

17
bikeshop_project/registration/tests/test_views.py

@ -82,6 +82,23 @@ class TestMemberSearchView(TestCase):
self.assertTrue([result['name'] for result in results
if self.query in result['name']])
def test_search_name_with_space(self):
mommy.make(Member, first_name="Test", last_name="Person")
url = reverse('member_search', kwargs=dict(query='Test Person'))
c = Client()
c.force_login(self.user)
response = c.get(url)
self.assertEqual(response.status_code, 200)
data = json.loads(response.content.decode(encoding='utf-8'))
results = data['results']
# Check if our made up first name is in the name returned.
self.assertTrue([result['name'] for result in results
if 'Test Person' in result['name']])
class TestMemberSignIn(TestCase):
def setUp(self):

2
bikeshop_project/registration/urls.py

@ -8,7 +8,7 @@ apiRoutes = (
urlpatterns = [
url(r'^new/$', MemberFormView.as_view(), name='member_new'),
url(r'^search/(?P<query>[\w@\.\+]+)/$', MemberSearchView.as_view(), name='member_search'),
url(r'^search/(?P<query>[\w|\W]+)/$', MemberSearchView.as_view(), name='member_search'),
url(r'^edit/(?P<member_id>[0-9]+)/$', MemberFormView.as_view(), name='member_edit'),
url(r'^signin/$', MemberSignIn.as_view(), name='member_signin'),
url(r'^$', Members.as_view(), name='members'),

Loading…
Cancel
Save