Fix publishing draft captions on file attachments and screenshots.

Review Request #9365 — Created Nov. 13, 2017 and submitted

Review Board

A recent change for 3.0 introduced counter fields for attachments and
screenshots, aiming to reduce queries on review requests and to simplify
publishing changes. The publishing work introduced a bug where the
conditions required for turning draft captions into captions was not met
when adding attachments or screenshots to a review request that didn't
already have one.

This change fixes that bug and improves our unit tests, which weren't
catching this before partly due to not reloading the objects from the
database and partly due to not sanity-checking the resulting captions.

Created a review request and added some file attachments to it. Set the
captions and published the review request. Saw that the captions were
still present both for my user and an anonymous user (previously, they'd
show "No Caption").

Unit tests pass.

  1. Ship It!
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-3.0.x (42e75f1)