Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

Reset the editor/reviewer comments when not specified #1394

Merged
merged 1 commit into from
Jun 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ This document describes changes between each past release.

- Removed ability to resign using ``to-sign`` twice. Use to ``to-resign`` instead.

**Bug fixes**

- Reset the editor/reviewer comments when not specified.


8.0.1 (2021-02-23)
------------------
Expand Down
9 changes: 8 additions & 1 deletion kinto_signer/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,11 @@ def rollback_changes(self, request, refresh_last_edit=True, refresh_signature=Fa
if refresh_last_edit:
current_userid = request.prefixed_userid
current_date = datetime.datetime.now(datetime.timezone.utc).isoformat()
attrs = {"status": STATUS.SIGNED.value}
attrs = {
"status": STATUS.SIGNED.value,
"last_editor_comment": "",
"last_reviewer_comment": "",
}
attrs[TRACKING_FIELDS.LAST_EDIT_BY.value] = current_userid
attrs[TRACKING_FIELDS.LAST_EDIT_DATE.value] = current_date
self._update_source_attributes(request, **attrs)
Expand Down Expand Up @@ -409,6 +413,9 @@ def update_source_status(self, status, request, old_status=None):
if status == STATUS.TO_REVIEW:
attrs[TRACKING_FIELDS.LAST_REVIEW_REQUEST_BY.value] = current_userid
attrs[TRACKING_FIELDS.LAST_REVIEW_REQUEST_DATE.value] = current_date
# Make sure we reset the review comments if none is specified.
if "last_editor_comment" not in request.validated["body"].get("data", {}):
attrs["last_editor_comment"] = ""
if status == STATUS.SIGNED:
if old_status != STATUS.SIGNED:
# Do not keep track of reviewer when refreshing signature.
Expand Down
39 changes: 39 additions & 0 deletions tests/test_signoff_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,26 @@ def test_tracking_fields_are_updated(self):
after_date = resp.json["data"]["last_edit_date"]
assert before_date != after_date

def test_comments_are_reset(self):
self.app.patch_json(
self.source_collection,
{
"data": {
"last_editor_comment": "please check that",
"last_reviewer_comment": "looks good",
}
},
headers=self.headers,
)

self.app.patch_json(
self.source_collection, {"data": {"status": "to-rollback"}}, headers=self.headers
)

resp = self.app.get(self.source_collection, headers=self.headers)
assert resp.json["data"]["last_editor_comment"] == ""
assert resp.json["data"]["last_reviewer_comment"] == ""

def test_recreates_deleted_record(self):
resp = self.app.delete(
self.source_collection + "/records?_limit=1&_sort=last_modified", headers=self.headers
Expand Down Expand Up @@ -955,6 +975,25 @@ def test_the_preview_collection_is_emptied_when_source_is_deleted(self):
records = resp.json["data"]
assert len(records) == 0

def test_last_editor_comment_are_reset_on_review(self):
self.app.patch_json(
self.source_collection,
{
"data": {
"last_editor_comment": "please check that",
"last_reviewer_comment": "looks good",
}
},
headers=self.headers,
)

self.app.patch_json(
self.source_collection, {"data": {"status": "to-review"}}, headers=self.headers
)

resp = self.app.get(self.source_collection, headers=self.headers)
assert resp.json["data"]["last_editor_comment"] == ""


class CollectionDelete(SignoffWebTest, unittest.TestCase):
@classmethod
Expand Down