'Test with a spam user who has made multiple revisions to a single
document.  This document should be reverted to the last version that was
created by a non-spam user (self.admin).
The original revision was created by the admin and then three more were
created by the spammer, with no addition revisions afterwards, so we
should wind up reverting to the original revision.'

def test_multiple_revisions_are_spam(self):

    self.create_revisions(num=1, document=self.document, creator=self.admin)
    spam_revisions = self.create_revisions(num=3, document=self.document, creator=self.testuser)
    self.client.login(username='admin', password='testpass')
    ban_url = reverse('users.ban_user_and_cleanup_summary', kwargs={'username': self.testuser.username})
    full_ban_url = self.client.get(ban_url)['Location']
    data = {'revision-id': [rev.id for rev in spam_revisions]}
    resp = self.client.post(full_ban_url, data=data)
    eq_(200, resp.status_code)
    page = pq(resp.content)
    revisions_deleted = page.find('#revisions-deleted    li')
    revisions_reverted = page.find('#revisions-reverted    li')
    eq_(len(revisions_deleted), 0)
    eq_(len(revisions_reverted), 1)
    revisions_added_afterwards = page.find('#new-actions-by-user    li')
    revisions_skipped = page.find('#skipped-revisions    li')
    revisions_reported_as_spam = page.find('#revisions-reported-as-spam    li')
    eq_(len(revisions_added_afterwards), 0)
    eq_(len(revisions_skipped), 0)
    eq_(len(revisions_reported_as_spam), 1)
    revisions_not_reverted = page.find('#latest-revision-non-spam    li')
    revisions_already_spam = page.find('#already-spam    li')
    revisions_not_spam = page.find('#not-spam    li')
    eq_(len(revisions_not_reverted), 0)
    eq_(len(revisions_already_spam), 0)
    eq_(len(revisions_not_spam), 0)
