Browse Source

Fix: Search path supports queries with all non-whitespace characters.

issue52
Drew Larson 8 years ago
parent
commit
00877e22b3
  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 self.assertTrue([result['name'] for result in results
if self.query in result['name']]) 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): class TestMemberSignIn(TestCase):
def setUp(self): def setUp(self):

2
bikeshop_project/registration/urls.py

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

Loading…
Cancel
Save