'Test voting via ajax.'

def test_vote_ajax(self):

    r = self.document.current_revision
    referrer = ''
    query = ''
    url = reverse('wiki.document_vote', args=[self.document.slug])
    response = self.client.post(url, data={'helpful': 'Yes', 'revision_id': r.id, 'referrer': referrer, 'query': query}, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
    eq_(200, response.status_code)
    eq_('{"message":    "Glad    to    hear    it    &mdash;    thanks    for    the    feedback!"}', response.content)
    votes = HelpfulVote.objects.filter(revision=r, creator=None)
    votes = votes.exclude(anonymous_id=None)
    eq_(1, votes.count())
    assert votes[0].helpful
    metadata = HelpfulVoteMetadata.objects.values_list('key', 'value')
    eq_(0, len(metadata))
