Permalink
Browse files

Add tests for page redirects, and fix subdomain.

  • Loading branch information...
1 parent 8c8399d commit 875df7c1f939be8c19b1bcf2162a29c1964d568c @ericholscher ericholscher committed Nov 13, 2012
Showing with 18 additions and 6 deletions.
  1. +6 −6 readthedocs/core/subdomain_urls.py
  2. +12 −0 readthedocs/rtd_tests/tests/test_redirects.py
@@ -15,17 +15,17 @@
'core.views.serve_docs',
name='docs_detail'
),
- url(r'^page/(?P<filename>.*)$',
- 'core.views.serve_docs',
- {'version_slug': None,
- 'lang_slug': None},
- name='docs_detail'
- ),
url(r'^(?P<lang_slug>\w{2})/(?P<version_slug>.*)/$',
'core.views.serve_docs',
{'filename': 'index.html'},
name='docs_detail'
),
+ url(r'^page/(?P<filename>.*)$',
+ 'core.views.subdomain_handler',
+ {'version_slug': None,
+ 'lang_slug': None},
+ name='docs_detail'
+ ),
url(r'^(?P<version_slug>.*)/$',
'core.views.subdomain_handler',
name='version_subdomain_handler'
@@ -46,3 +46,15 @@ def test_inproper_subdomain(self):
def test_proper_subdomain_and_url(self):
r = self.client.get('/en/latest/', HTTP_HOST = 'pip.readthedocs.org')
self.assertEqual(r.status_code, 200)
+
+ # Specific Page Redirects
+ def test_proper_page_on_subdomain(self):
+ r = self.client.get('/page/test.html', HTTP_HOST = 'pip.readthedocs.org')
+ self.assertEqual(r.status_code, 302)
+ self.assertEqual(r._headers['location'], ('Location', 'http://pip.readthedocs.org/en/latest/test.html'))
+
+ # Specific Page Redirects
+ def test_proper_page_on_main_site(self):
+ r = self.client.get('/docs/pip/page/test.html')
+ self.assertEqual(r.status_code, 302)
+ self.assertEqual(r._headers['location'], ('Location', 'http://testserver/docs/pip/en/latest/test.html'))

0 comments on commit 875df7c

Please sign in to comment.