mirror of
https://github.com/wagtail/wagtail.git
synced 2024-11-29 09:33:54 +01:00
Fix assertRedirects to use local URLs where appropriate
This commit is contained in:
parent
37c9913a35
commit
1499715e43
@ -276,7 +276,7 @@ class TestFrontendServeView(TestCase):
|
||||
signature = generate_signature(self.image.id, 'fill-800x600')
|
||||
response = self.client.get(reverse('wagtailimages_serve_action_redirect', args=(signature, self.image.id, 'fill-800x600')))
|
||||
|
||||
expected_redirect_url = 'http://testserver/media/images/{filename[0]}.2e16d0ba.fill-800x600{filename[1]}'.format(
|
||||
expected_redirect_url = '/media/images/{filename[0]}.2e16d0ba.fill-800x600{filename[1]}'.format(
|
||||
filename=os.path.splitext(os.path.basename(self.image.file.path))
|
||||
)
|
||||
|
||||
|
@ -146,7 +146,9 @@ class TestRedirects(TestCase):
|
||||
models.Redirect.objects.create(old_path='/xmas', redirect_page=christmas_page)
|
||||
|
||||
response = self.client.get('/xmas/', HTTP_HOST='test.example.com')
|
||||
self.assertRedirects(response, 'http://test.example.com/events/christmas/', status_code=301, fetch_redirect_response=False)
|
||||
# Only one site defined, so redirect should return a local URL
|
||||
# (to keep things working if Site records haven't been configured correctly)
|
||||
self.assertRedirects(response, '/events/christmas/', status_code=301, fetch_redirect_response=False)
|
||||
|
||||
def test_redirect_from_any_site(self):
|
||||
contact_page = Page.objects.get(url_path='/home/contact-us/')
|
||||
@ -219,7 +221,7 @@ class TestRedirects(TestCase):
|
||||
|
||||
response = self.client.get('/xmas/', HTTP_HOST='other.example.com')
|
||||
# the redirect which matched was /site-specific
|
||||
self.assertRedirects(response, 'http://other.example.com/site-specific', status_code=301, fetch_redirect_response=False)
|
||||
self.assertRedirects(response, '/site-specific', status_code=301, fetch_redirect_response=False)
|
||||
|
||||
def test_duplicate_redirects_with_query_string_when_match_is_for_specific_with_qs(self):
|
||||
contact_page = Page.objects.get(url_path='/home/contact-us/')
|
||||
@ -235,12 +237,12 @@ class TestRedirects(TestCase):
|
||||
|
||||
response = self.client.get('/xmas/?foo=Bar', HTTP_HOST='other.example.com')
|
||||
# the redirect which matched was /site-specific-with-query-string
|
||||
self.assertRedirects(response, 'http://other.example.com/site-specific-with-query-string', status_code=301, fetch_redirect_response=False)
|
||||
self.assertRedirects(response, '/site-specific-with-query-string', status_code=301, fetch_redirect_response=False)
|
||||
|
||||
# now use a non-matching query string
|
||||
response = self.client.get('/xmas/?foo=Baz', HTTP_HOST='other.example.com')
|
||||
# the redirect which matched was /site-specific
|
||||
self.assertRedirects(response, 'http://other.example.com/site-specific', status_code=301, fetch_redirect_response=False)
|
||||
self.assertRedirects(response, '/site-specific', status_code=301, fetch_redirect_response=False)
|
||||
|
||||
def test_duplicate_page_redirects_when_match_is_for_specific(self):
|
||||
contact_page = Page.objects.get(url_path='/home/contact-us/')
|
||||
|
Loading…
Reference in New Issue
Block a user