@@ -58,6 +58,14 @@ def test_proper_page_on_main_site(self):
58
58
'http://readthedocs.org/docs/pip/en/latest/test.html' ,
59
59
)
60
60
61
+ def test_page_redirect_with_query_params (self ):
62
+ r = self .client .get ('/docs/pip/page/test.html?foo=bar' )
63
+ self .assertEqual (r .status_code , 302 )
64
+ self .assertEqual (
65
+ r ['Location' ],
66
+ 'http://readthedocs.org/docs/pip/en/latest/test.html?foo=bar'
67
+ )
68
+
61
69
# If slug is neither valid lang nor valid version, it should 404.
62
70
# TODO: This should 404 directly, not redirect first
63
71
def test_improper_url_with_nonexistent_slug (self ):
@@ -97,6 +105,15 @@ def test_proper_subdomain(self):
97
105
r ['Location' ], 'http://pip.readthedocs.org/en/latest/' ,
98
106
)
99
107
108
+ @override_settings (USE_SUBDOMAIN = True )
109
+ def test_root_redirect_with_query_params (self ):
110
+ r = self .client .get ('/?foo=bar' , HTTP_HOST = 'pip.readthedocs.org' )
111
+ self .assertEqual (r .status_code , 302 )
112
+ self .assertEqual (
113
+ r ['Location' ],
114
+ 'http://pip.readthedocs.org/en/latest/?foo=bar'
115
+ )
116
+
100
117
# Specific Page Redirects
101
118
@override_settings (USE_SUBDOMAIN = True )
102
119
def test_proper_page_on_subdomain (self ):
@@ -190,6 +207,21 @@ def test_redirect_page(self):
190
207
r ['Location' ], 'http://pip.readthedocs.org/en/latest/tutorial/install.html' ,
191
208
)
192
209
210
+ @override_settings (USE_SUBDOMAIN = True )
211
+ def test_redirect_with_query_params (self ):
212
+ Redirect .objects .create (
213
+ project = self .pip , redirect_type = 'page' ,
214
+ from_url = '/install.html' , to_url = '/tutorial/install.html'
215
+ )
216
+ r = self .client .get (
217
+ '/install.html?foo=bar' , HTTP_HOST = 'pip.readthedocs.org'
218
+ )
219
+ self .assertEqual (r .status_code , 302 )
220
+ self .assertEqual (
221
+ r ['Location' ],
222
+ 'http://pip.readthedocs.org/en/latest/tutorial/install.html?foo=bar'
223
+ )
224
+
193
225
@override_settings (USE_SUBDOMAIN = True )
194
226
def test_redirect_exact (self ):
195
227
Redirect .objects .create (
0 commit comments