Commit 3b2c29ca authored by Raphaël Hertzog's avatar Raphaël Hertzog

Merge branch 'issue-6-accept-trailing-slash-news-url' into 'master'

Accept trailing slash on news URL Closes #6 See merge request !18
parents 2e5397ec 6a7c9d1a
Pipeline #3102 passed with stages
in 9 minutes 14 seconds
......@@ -1781,6 +1781,19 @@ class NewsViewTest(TestCase, TemplateTestsMixin):
else:
return self.client.get('%s?page=%s' % (self.news_url, page))
def test_news_page_urls(self):
"""
Tests all possibile urls to access the page of a single news
"""
news = self.package.news_set.first()
url = reverse('dtracker-news-page', kwargs={'news_id': news.id})
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
response = self.client.get(url + '/')
self.assertEqual(response.status_code, 200)
response = self.client.get(news.get_absolute_url())
self.assertEqual(response.status_code, 200)
def test_news_page_has_link_to_package_page(self):
response = self.get_package_news()
self.assertLinkIsInResponse(response, package_url(self.package))
......
......@@ -103,7 +103,7 @@ urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^news/(?P<news_id>\d+)$', news_page,
url(r'^news/(?P<news_id>\d+)/?$', news_page,
name='dtracker-news-page'),
url(r'^news/(?P<news_id>\d+)/(?P<slug>.+)/$', news_page,
name='dtracker-news-page'),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment