'Recent helpful votes are indexed properly.'

def test_recent_helpful_votes(self):

    r = RevisionFactory(is_approved=True)
    self.refresh()
    eq_(DocumentMappingType.search().filter(document_recent_helpful_votes__gt=0).count(), 0)
    HelpfulVoteFactory(revision=r, helpful=False)
    r.document.save()
    self.refresh()
    eq_(DocumentMappingType.search().filter(document_recent_helpful_votes__gt=0).count(), 0)
    created = (datetime.now() - timedelta(days=31))
    HelpfulVoteFactory(revision=r, helpful=True, created=created)
    r.document.save()
    self.refresh()
    eq_(DocumentMappingType.search().filter(document_recent_helpful_votes__gt=0).count(), 0)
    created = (datetime.now() - timedelta(days=29))
    HelpfulVoteFactory(revision=r, helpful=True, created=created)
    r.document.save()
    self.refresh()
    eq_(DocumentMappingType.search().filter(document_recent_helpful_votes__gt=0).count(), 1)
