diff --git a/bikeshop_project/registration/tests/test_views.py b/bikeshop_project/registration/tests/test_views.py index 5b15d96..b4e08c4 100644 --- a/bikeshop_project/registration/tests/test_views.py +++ b/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): diff --git a/bikeshop_project/registration/urls.py b/bikeshop_project/registration/urls.py index e861aa9..0768c4d 100644 --- a/bikeshop_project/registration/urls.py +++ b/bikeshop_project/registration/urls.py @@ -8,7 +8,7 @@ apiRoutes = ( urlpatterns = [ url(r'^new/$', MemberFormView.as_view(), name='member_new'), - url(r'^search/(?P[\w@\.\+]+)/$', MemberSearchView.as_view(), name='member_search'), + url(r'^search/(?P[\w|\W]+)/$', MemberSearchView.as_view(), name='member_search'), url(r'^edit/(?P[0-9]+)/$', MemberFormView.as_view(), name='member_edit'), url(r'^signin/$', MemberSignIn.as_view(), name='member_signin'), url(r'^$', Members.as_view(), name='members'),