'Tests that ensures_csrf_cookie decorator fulfils its promise
with the middleware enabled.'

def test_ensures_csrf_cookie_with_middleware(self):

    @ensure_csrf_cookie
    def view(request):
        return HttpResponse(content=u'')
    req = self._get_GET_no_csrf_cookie_request()
    CsrfViewMiddleware().process_view(req, view, (), {})
    resp = view(req)
    resp2 = CsrfViewMiddleware().process_response(req, resp)
    self.assertTrue(resp2.cookies.get(settings.CSRF_COOKIE_NAME, False))
    self.assertTrue((u'Cookie' in resp2.get(u'Vary', u'')))
