'Make sure documents with REDIRECT directives redirect properly.
Also check the backlink to the redirect page.'

def test_redirect(self):

    target = DocumentFactory()
    target_url = target.get_absolute_url()
    redirect = RedirectRevisionFactory(target=target).document
    redirect_url = redirect.get_absolute_url()
    response = self.client.get(redirect_url, follow=True)
    self.assertRedirects(response, urlparams(target_url, redirectlocale=redirect.locale, redirectslug=redirect.slug))
    self.assertContains(response, (redirect_url + '?redirect=no'))
    doc = pq(response.content)
    eq_(target_url, doc('link[rel=canonical]').attr('href'))
