'HTTP POST to new revision URL creates the revision on a document.
The document in this case already has a current_revision, therefore
the document document fields are not editable.
Also assert that the edited and reviewable notifications go out.'

@mock.patch.object(Site.objects, 'get_current')
@mock.patch.object(settings._wrapped, 'TIDINGS_CONFIRM_ANONYMOUS_WATCHES', False)
def test_new_revision_POST_document_with_current(self, get_current):

    get_current.return_value.domain = 'testserver'
    edit_watch = EditDocumentEvent.notify('sam@example.com', self.d)
    edit_watch.activate().save()
    review_user = UserFactory(email='joe@example.com')
    add_permission(review_user, Revision, 'review_revision')
    reviewable_watch = ReviewableRevisionInLocaleEvent.notify(review_user, locale='en-US')
    reviewable_watch.activate().save()
    reviewable_watch_no_permission = ReviewableRevisionInLocaleEvent.notify(UserFactory(), locale='en-US')
    reviewable_watch_no_permission.activate().save()
    response = self.client.post(reverse('wiki.edit_document', args=[self.d.slug]), {'summary': 'A    brief    summary', 'content': 'The    article    content', 'keywords': 'keyword1    keyword2', 'comment': 'Fixing    all    the    typos!!!!!11!!!one!!!!', 'based_on': self.d.current_revision.id, 'form': 'rev'})
    eq_(302, response.status_code)
    eq_(2, self.d.revisions.count())
    new_rev = self.d.revisions.order_by('-id')[0]
    eq_(self.d.current_revision, new_rev.based_on)
    if (new_rev.based_on is not None):
        diff = get_diff_for(new_rev.based_on.document, new_rev.based_on, new_rev)
    else:
        diff = ''
    eq_(2, len(mail.outbox))
    attrs_eq(mail.outbox[0], subject=(u'%s    is    ready    for    review    (%s)' % (self.d.title, new_rev.creator)), body=(READY_FOR_REVIEW_EMAIL_CONTENT % {'user': self.user.profile.name, 'title': self.d.title, 'slug': self.d.slug, 'new_id': new_rev.id, 'summary': new_rev.summary, 'diff': diff, 'watcher': reviewable_watch.pk, 'secret': reviewable_watch.secret}), to=['joe@example.com'])
    attrs_eq(mail.outbox[1], subject=(u'%s    was    edited    by    %s' % (self.d.title, new_rev.creator)), body=(DOCUMENT_EDITED_EMAIL_CONTENT % {'user': self.user.profile.name, 'title': self.d.title, 'slug': self.d.slug, 'watcher': edit_watch.pk, 'secret': edit_watch.secret, 'summary': new_rev.summary, 'diff': diff}), to=['sam@example.com'])
