Don't allow publishing empty review

Review Request #10834 — Created Jan. 18, 2020 and updated — Latest diff uploaded

Information

Review Board
release-3.0.x

Reviewers

When making an empty review (i.e., no comment, body top, body bottom,
or Ship It) the review is recognized as a valid review and can be
published. The problem is that when a review is detected as empty,
the code doesn't raise a publish error so the empty review being
published is blocked.

I added a function to detect empty reviews. Once an empty review is
trying to be published, an error is raised and the public state rolls
back to previous state so it doesn't mess up the state when an error
occurs (public state is a bool - when it's true, the review
is considered as published).

Create a new review -> publish -> publish failed.
Create a new review -> give a comment -> delete the comment -> publish -> publish failed.
Create a new review -> give a header -> delete the header -> publish -> publish failed.
Create a new review -> give a footer -> delete the footer -> publish -> publish failed.
Create a new review -> check "Ship-It" -> publish -> publish success.

Diff Revision 4

This is not the most recent revision of the diff. The latest diff is revision 6. See what's changed.

orig
1
2
3
4
5
6

Commits

First Last Summary ID Author
Don't allow publishing empty review
79a9e95c26d4437434d1cff3a24afac4ac1a62ca Xiaohui Liu
Delete extra spaces.
e302fe5b4d9a93739582169d7ea09379adeec795 Xiaohui Liu
unit tests added
77361f2ccd649efa6c1547c1d4107ab9cc7eb70f Xiaohui Liu
remove extra spaces
9e1cb9b46acfebefa82e1089adddbd087bfc5b70 Xiaohui Liu
modify multi-line str to pass flake8
ecc729eed7ed820f9866f718c3e8f54ed0aa9ab2 Xiaohui Liu
reviewboard/reviews/models/review.py
reviewboard/reviews/tests/test_review.py
reviewboard/static/rb/js/resources/models/draftReviewModel.es6.js
reviewboard/static/rb/js/resources/models/tests/draftReviewModelTests.js
reviewboard/static/rb/js/views/draftReviewBannerView.es6.js
Loading...