Fix bugs related to general comments and Ship It indications in review emails.
Review Request #8240 — Created June 12, 2016 and submitted — Latest diff uploaded
Address two inconsistencies where general comments were not being handled in
the same fashion as the other classes of comments (e.g. diff, file attachment,
and screenshot comments). These would lead to errant details in review emails
for reviews where a Ship It had been declared.
- The existence of general comments was not being considered when determining
theship_it_only
state ofReview
objects. This resulted in review emails
where theX-ReviewBoard-ShipIt-Only
header was set even when general comments
were present.- The existence of general comments with open issues was not being considered
when determining the need for the "Fix it, then Ship it!" designation for review
emails. This produced review emails with the "Ship it!" designation, even when
the review contained general comments with issues.To resolve both bugs, separate queries that accounted for the other three
classes of comments were centralized into a new function,has_comments()
,
and a query for general comments was introduced here as well. Furthermore, with
respect to item 2, the logic for determining the presence of any comments with
issues is now conditioned onreview.ship_it
, since this is the only state under
which this information is necessary. Previously this was calculated
unconditionally, which was overkill.To facilitate consistency and testability, a
FIX_IT_THEN_SHIP_IT_TEXT
constant has been added to theReview
class to hold the
"Fix it, then Ship it!" text. This is analogous toSHIP_IT_TEXT
which
already exists. These constants are now utilized in the review email templates
rather than the prior string literals. This introduces one minor delta for
Ship It emails. Previously, the string literal was "Ship it!", whereas the
string inSHIP_IT_TEXT
is "Ship It!'. That is, the "I" in "It" is now
capitalized.Also, added
GeneralComment
to the list of comment classes discussed in the
documentation for theCommentDetailDisplayHook
.
- Augmented all existing unit tests related to review emails with Ship It to
verify that "Fix it, then Ship it!" does not appear in the message. - Added a new unit test for review emails with a Ship It and general
comments. This is analogous to existing tests for the other three classes of
comments. This test would fail without the fix. - Added new unit tests for all four classes of comments to further test review
email's with a Ship It and comments with an opened issue. Prior to the fix,
the specific test for the general comment class would fail.
Confirmed all unit tests pass. Built docs and reviewed.