Skip to content

Commit

Permalink
Fix #272: Prevents commenter from being assigned after PTAL comment (#…
Browse files Browse the repository at this point in the history
…285)

* fix

* minor nit

* added tests
  • Loading branch information
gp201 authored Aug 23, 2021
1 parent 20f6ec2 commit 6c7f056
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/checkPullRequestReview.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ const handleResponseToReview = async (context) => {
(assignee) => assignee.login
);
const unassignedUsers = usersInComment.filter(
(user) => !assignees.includes(user)
(user) => !assignees.includes(user) && user !== commenter
);

if (unassignedUsers.length === 0) {
Expand Down
24 changes: 24 additions & 0 deletions spec/checkPullRequestReviewSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1627,5 +1627,29 @@ describe('Pull Request Review Module', () => {
commentPayloadData.payload.comment.body = initialCommentBody;
});
});

describe('when commenter self references in comment', () => {
const initialCommentBody = commentPayloadData.payload.comment.body;
beforeAll(() => {
commentPayloadData.payload.comment.body = (
'@testuser @reviewer1 PTAL');
});
beforeEach(async () => {
await robot.receive(commentPayloadData);
});

it('should not assign commenter to the PR', () => {
expect(github.issues.addAssignees).toHaveBeenCalledWith({
repo: commentPayloadData.payload.repository.name,
owner: commentPayloadData.payload.repository.owner.login,
issue_number: commentPayloadData.payload.issue.number,
assignees: ['reviewer1'],
});
});

afterAll(() => {
commentPayloadData.payload.comment.body = initialCommentBody;
});
});
});
});

0 comments on commit 6c7f056

Please sign in to comment.