Fix the issue of publishing from web API without reviewers or groups specified.

Review Request #9210 — Created Sept. 23, 2017 and submitted

Information

Review Board
master
f5e16b3...

Reviewers

When creating a new review request with no reviewer or groups
assigned, attempting to publish it with PUT will be sucessful.
However, it shouldn't allow that as review requests must have a
reviewer. The issue is solved by adding conditions to validate the
review draft on the server.

Added a unit test, which passes (along with all other tests).

  • Created a draft test review that don't have a reviewer/group name.
  • Ran it using this command ./tests/runtests.py
    reviewboard.reviews.tests.test_review_request_draft
  • This will raise a publishingError since there isn't reviewer.
  • Fixed other unit tests that failed because of the change.
Description From Last Updated

The summary doesn't tell me anything. From the summary alone, I should be able to have a clear idea of …

chipx86chipx86

Please wrap your description at 72 characters.

brenniebrennie

Instead of including a URL in the description you can just name the resource involved.

brenniebrennie

Please wrap your description at 72 characters.

brenniebrennie

The summary should be in sentence casing.

chipx86chipx86

You still need to wrap your description at 72 characters per line.

brenniebrennie

I'd like to see a little more here with this change. Right now, the validation happens client-side in JavaScript for …

chipx86chipx86

Shouldn't add parenthesis here. We only use them if spanning lines.

chipx86chipx86

This blank line shouldn't be added.

chipx86chipx86

Too many blank lines.

chipx86chipx86

E265 block comment should start with '# '

reviewbotreviewbot

E303 too many blank lines (2)

reviewbotreviewbot

This should go away.

chipx86chipx86

The web UI currently displays an error message for this case, so we should use that exact string.

chipx86chipx86

You should remove the blank lines you added here.

chipx86chipx86

Too many blank lines. There should be 2.

chipx86chipx86

E303 too many blank lines (2)

reviewbotreviewbot

F841 local variable 'old_summary' is assigned to but never used

reviewbotreviewbot

F841 local variable 'old_description' is assigned to but never used

reviewbotreviewbot

F841 local variable 'old_testing_done' is assigned to but never used

reviewbotreviewbot

F841 local variable 'old_branch' is assigned to but never used

reviewbotreviewbot

F841 local variable 'old_bugs' is assigned to but never used

reviewbotreviewbot

Just one blank line here.

chipx86chipx86

E303 too many blank lines (3)

reviewbotreviewbot

This should test for the error message as well.

chipx86chipx86

W391 blank line at end of file

reviewbotreviewbot

Too many blank lines. You should remove the ones you added.

chipx86chipx86

W291 trailing whitespace

reviewbotreviewbot

E501 line too long (114 > 79 characters)

reviewbotreviewbot

W292 no newline at end of file

reviewbotreviewbot

E501 line too long (114 > 79 characters)

reviewbotreviewbot

W291 trailing whitespace

reviewbotreviewbot

E501 line too long (106 > 79 characters)

reviewbotreviewbot

E501 line too long (106 > 79 characters)

reviewbotreviewbot

This newline should be removed.

mike_conleymike_conley

Glad you added a test for the lack of reviewers, but can you add some tests for the lack of …

mike_conleymike_conley

These extra newlines should be removed.

mike_conleymike_conley

This extra newline should be removed.

mike_conleymike_conley

E999 SyntaxError: EOL while scanning string literal

reviewbotreviewbot

W291 trailing whitespace

reviewbotreviewbot

E128 continuation line under-indented for visual indent

reviewbotreviewbot

E124 closing bracket does not match visual indentation

reviewbotreviewbot

W291 trailing whitespace

reviewbotreviewbot

E128 continuation line under-indented for visual indent

reviewbotreviewbot

E124 closing bracket does not match visual indentation

reviewbotreviewbot

E128 continuation line under-indented for visual indent

reviewbotreviewbot

E124 closing bracket does not match visual indentation

reviewbotreviewbot

W292 no newline at end of file

reviewbotreviewbot

These need to be marked for translation with ugettext.

brenniebrennie

Single quotes. This should be marked for translation with ugettext.

brenniebrennie

Single quotes. This should be marked for translation with ugettext.

brenniebrennie

Single quotes. This should be marked for translation with ugettext.

brenniebrennie

Undo this.

brenniebrennie

This needs to be localized (using ugettext).

chipx86chipx86

These as well.

chipx86chipx86

This can be one statement.

chipx86chipx86

Imports must be included alphabetically.

chipx86chipx86

"publish" isn't explicit enough when looking at a whole list of tests. We prefer including the class name. Can you …

chipx86chipx86

You don't need to define this function anymore, since it's just chaining up.

chipx86chipx86

E501 line too long (88 > 79 characters)

reviewbotreviewbot

These can go on the same line.

brenniebrennie

Undo this.

brenniebrennie

Alphabetical order.

brenniebrennie

Why are we no longer doing this client side? It save s a round trip.

brenniebrennie

This looks like your project is starting to leak into your EasyFix. You'll want to separate them, and do project …

mike_conleymike_conley

This doesn't need the parens around it (we only use them if the list of imports wraps to multiple lines).

daviddavid

Parens can go on the same line as the last part of the text.

daviddavid

Moving this line doesn't seem to be changing functionality but it is making the imports no longer alphabetically sorted.

bleblan2bleblan2

This import is also not in alphabetical order (e before f).

bleblan2bleblan2

Grammar isn't quite right--needs to be "isn't a reviewer"

daviddavid

This is the test for not having a description but you're checking for the error about not having a summary. …

bleblan2bleblan2

W292 no newline at end of file

reviewbotreviewbot

W292 no newline at end of file

reviewbotreviewbot

W391 blank line at end of file

reviewbotreviewbot

W293 blank line contains whitespace

reviewbotreviewbot

E265 block comment should start with '# '

reviewbotreviewbot

E265 block comment should start with '# '

reviewbotreviewbot

E265 block comment should start with '# '

reviewbotreviewbot

E265 block comment should start with '# '

reviewbotreviewbot

E265 block comment should start with '# '

reviewbotreviewbot

E501 line too long (97 > 79 characters)

reviewbotreviewbot

E265 block comment should start with '# '

reviewbotreviewbot

E501 line too long (105 > 79 characters)

reviewbotreviewbot

E265 block comment should start with '# '

reviewbotreviewbot
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.

flake8

chipx86
  1. 
      
  2. Show all issues

    The summary doesn't tell me anything. From the summary alone, I should be able to have a clear idea of the purpose of this change. As it is, I have to know what reviewers name issue you're talking about.

    The description also needs a lot more fleshing out. I want to see what the problem was, why it was a problem, how it was fixed. Look at the Writing Good Change Descriptions guide for details on what we expect.

    Content must also wrap to 70-75 characters in your description/testing.

    Testing Done's content needs some work as well. I'd suggest getting a mentor and having him go over ways to make the testing clear and succint.

  3. Show all issues

    I'd like to see a little more here with this change. Right now, the validation happens client-side in JavaScript for this field. The client also validates the summary and description. Both of these should also move into the server-side validation in your change (and you should summarize the change appropriately, like "Move UI-side validation for required review request fields into the backend"). You should then get rid of the client-side versions of these so we only have one validation codepath to go through.

  4. Show all issues

    Shouldn't add parenthesis here. We only use them if spanning lines.

  5. reviewboard/reviews/models/review_request_draft.py (Diff revision 1)
     
     
     
     
     
     
    Show all issues

    This blank line shouldn't be added.

  6. reviewboard/reviews/models/review_request_draft.py (Diff revision 1)
     
     
     
     
     
     
    Show all issues

    Too many blank lines.

  7. Show all issues

    This should go away.

  8. Show all issues

    The web UI currently displays an error message for this case, so we should use that exact string.

  9. reviewboard/reviews/models/review_request_draft.py (Diff revision 1)
     
     
     
     
     
     
    Show all issues

    You should remove the blank lines you added here.

  10. reviewboard/reviews/tests/test_review_request_draft.py (Diff revision 1)
     
     
     
     
     
     
    Show all issues

    Too many blank lines. There should be 2.

  11. reviewboard/reviews/tests/test_review_request_draft.py (Diff revision 1)
     
     
     
     
     
     
    Show all issues

    Just one blank line here.

  12. Show all issues

    This should test for the error message as well.

  13. reviewboard/webapi/resources/review_request_draft.py (Diff revision 1)
     
     
     
     
     
     
    Show all issues

    Too many blank lines. You should remove the ones you added.

  14. 
      
MU
Review request changed
Summary:
Fixed reviewers name issue
Fixed the Issue of Publishing From Web API Without Reviewers or Groups Specified
Description:
~  

Fixed the Issue of Publishing From Web API Without Reviewers or Groups Specified

  ~

When creating a new review request with no reviewer or groups assigned, attempting to publish it with PUT .../api/review-requests/####/draft/ public=1 will be sucessful. However, it shouldn't allow that as review requests must have a reviewer. The issue is solved by adding conditions to validate the review draft on the server.

Testing Done:
-  

When user attempt to publish using PUT .../api/review-requests/####/draft/ public=1, the people or group names is not required. The user can submit the review request with no reviewers or groups assigned.

-   There weren't any condition to check for user or group name in the web API. This change checks for people or group name to see if they're entered or not.

-  
   

Added a unit test, which passes (along with all other tests).

   
~  

Tested by creating a draft review request without containing user/group names. After trying to publish it this will raise publish error.

  ~
  • Created a draft test review that don't have a reviewer/group name.
  +
  • Ran it using this command ./tests/runtests.py reviewboard.reviews.tests.test_review_request_draft
  +
  • This will raise a publishingError since there isn't reviewer.
Commit:
07f33dbc16e7d628d28e8adb606a7c09edd819a5
7b960f1130a660c49df6dc3086f46ae20a232740

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

MU
Review request changed
Commit:
7b960f1130a660c49df6dc3086f46ae20a232740
1d24398b63fcb1d14899bde171dc5b0040ea813c

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

MU
Review request changed
Commit:
1d24398b63fcb1d14899bde171dc5b0040ea813c
b0b96286e45e8057e1b1636b0ec8c4f2ee9540b7

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

MU
Review request changed
Commit:
b0b96286e45e8057e1b1636b0ec8c4f2ee9540b7
a77089f54749bc327013b8d511d78056a6a1db0b

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

MU
Review request changed
Commit:
a77089f54749bc327013b8d511d78056a6a1db0b
be52cc8e8e01c6d95edcd01aa090b273e79cee0d

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

mike_conley
  1. Looking good! Just a few more notes below.

  2. Show all issues

    This newline should be removed.

  3. reviewboard/reviews/models/review_request_draft.py (Diff revision 5)
     
     
     
     
     
     
    Show all issues

    Glad you added a test for the lack of reviewers, but can you add some tests for the lack of a summary or description too please, to round it out?

  4. Show all issues

    These extra newlines should be removed.

  5. Show all issues

    This extra newline should be removed.

  6. 
      
MU
Review request changed
Commit:
be52cc8e8e01c6d95edcd01aa090b273e79cee0d
b6dffa2eeed963a1e942526f08d5a75b7a8270b8

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

MU
brennie
  1. A few minor nitpicks.

  2. Show all issues

    Please wrap your description at 72 characters.

  3. Show all issues

    Instead of including a URL in the description you can just name the resource involved.

  4. Show all issues

    Single quotes.

    This should be marked for translation with ugettext.

  5. Show all issues

    Single quotes.

    This should be marked for translation with ugettext.

  6. Show all issues

    Single quotes.

    This should be marked for translation with ugettext.

  7. Show all issues

    Undo this.

  8. 
      
MU
brennie
  1. 
      
  2. Show all issues

    Please wrap your description at 72 characters.

  3. reviewboard/reviews/models/review_request_draft.py (Diff revisions 8 - 9)
     
     
     
     
     
     
     
     
     
     
     
    Show all issues

    These need to be marked for translation with ugettext.

  4. 
      
chipx86
  1. 
      
  2. Show all issues

    The summary should be in sentence casing.

    1. This was marked as fixed but wasn't done.

  3. Show all issues

    This needs to be localized (using ugettext).

  4. reviewboard/reviews/models/review_request_draft.py (Diff revision 9)
     
     
     
     
     
    Show all issues

    These as well.

  5. Show all issues

    This can be one statement.

  6. Show all issues

    Imports must be included alphabetically.

  7. Show all issues

    "publish" isn't explicit enough when looking at a whole list of tests. We prefer including the class name. Can you use "ReviewRequestDraft.publish"?

    Also, no blank line separating these.

    These comments apply below as well.

  8. reviewboard/static/rb/js/resources/models/draftReviewRequestModel.es6.js (Diff revision 9)
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    Show all issues

    You don't need to define this function anymore, since it's just chaining up.

  9. 
      
MU
Review request changed
Summary:
Fixed the Issue of Publishing From Web API Without Reviewers or Groups Specified
Fixed the Issue of Publishing From Web API Without Reviewers or Groups Specified.
Commit:
7a68c52fdfc99b64b78f3b7863b932bd6994efea
c0c86a0ca3728366e7cf736d563f466541e0d4ec

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

MU
MU
brennie
  1. 
      
  2. Show all issues

    You still need to wrap your description at 72 characters per line.

  3. Show all issues

    These can go on the same line.

  4. reviewboard/reviews/tests/test_review_request.py (Diff revision 11)
     
     
     
     
     
    Show all issues

    Undo this.

  5. reviewboard/reviews/tests/test_review_request_draft.py (Diff revision 11)
     
     
     
     
     
    Show all issues

    Alphabetical order.

  6. Show all issues

    Why are we no longer doing this client side? It save s a round trip.

    1. I used to have both server and client side, but Christian suggested doing this only on the server side.

  7. 
      
MU
mike_conley
  1. 
      
  2. reviewboard/datagrids/builtin_items.py (Diff revision 12)
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    Show all issues

    This looks like your project is starting to leak into your EasyFix. You'll want to separate them, and do project development on a separate branch. Ping me in Slack if you need help de-tangling this stuff.

  3. 
      
MU
david
  1. 
      
  2. Show all issues

    This doesn't need the parens around it (we only use them if the list of imports wraps to multiple lines).

  3. Show all issues

    Parens can go on the same line as the last part of the text.

  4. Show all issues

    Grammar isn't quite right--needs to be "isn't a reviewer"

  5. 
      
bleblan2
  1. 
      
  2. Show all issues

    Moving this line doesn't seem to be changing functionality but it is making the imports no longer alphabetically sorted.

  3. Show all issues

    This import is also not in alphabetical order (e before f).

  4. Show all issues

    This is the test for not having a description but you're checking for the error about not having a summary. This should probably be changed to set a summary on the draft and then the error should be about the description not being there.

  5. 
      
MU
Review request changed
Branch:
release-3.0.x
master
Commit:
ae36187944ab976c1c3dfa85e173aa59f0adef1f
6d1d668e854ef48bde23dca3a8b6aaa32f8a4d79

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

MU
Review request changed

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

MU
Review request changed
Commit:
6d1d668e854ef48bde23dca3a8b6aaa32f8a4d79
305520b7f15c7d40a6f2056107c9ce642e706804

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

MU
MU
mike_conley
MA
Review request changed
Change Summary:

Many of the unit tests were failing because they were not adding reviewers, summary, or description to review requests.

Fixed that by adding a boolean parameter in review request creator that defaults to adding reviewers. [WIP]

Summary:
Fixed the issue of publishing from web API without reviewers or groups specified.
Fixed the issue of publishing from web API without reviewers or groups specified. [WIP]
Testing Done:
   

Added a unit test, which passes (along with all other tests).

   
   
  • Created a draft test review that don't have a reviewer/group name.
   
  • Ran it using this command ./tests/runtests.py
    reviewboard.reviews.tests.test_review_request_draft
   
  • This will raise a publishingError since there isn't reviewer.
  +
  • Fixed other unit tests.
Commit:
a73e6ade4f583b68118f4c59560a6b62df3ae35d
95fefbd0d72c7bbc7128746aaee026123955e539

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

MA
MA
MA
MA
MA
david
  1. Ship It!
  2. 
      
MA
Review request changed
Status:
Completed
Change Summary:
Pushed to release-3.0.x (2857ab8)