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

Commit

Permalink
Merge pull request #1395 from Kinto/518-copy-schema-fields
Browse files Browse the repository at this point in the history
Copy schema field to destination metadata (fixes #518)
  • Loading branch information
leplatrem committed Jun 17, 2021
2 parents 944ac21 + c5d7447 commit 3fd963f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
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.

**New feature**

- Copy ``schema`` field to destination metadata (fixes #518)

**Bug fixes**

- Reset the editor/reviewer comments when not specified.
Expand Down
5 changes: 3 additions & 2 deletions kinto_signer/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

FIELD_ID = "id"
FIELD_LAST_MODIFIED = "last_modified"
# Source collection fields to be copied to destination.
PUBLISHED_COLLECTION_FIELDS = ("schema", "sort", "displayFields", "attachment")


class TRACKING_FIELDS(Enum):
Expand Down Expand Up @@ -371,8 +373,7 @@ def set_destination_signature(self, signature, source_attributes, request):
new_collection = dict(**collection_record)
new_collection.pop(FIELD_LAST_MODIFIED, None)
new_collection["signature"] = signature
# Copy some Kinto-Admin UI attributes from source to destination.
for attr in ("sort", "displayFields", "attachment"):
for attr in PUBLISHED_COLLECTION_FIELDS:
if attr in source_attributes:
new_collection.setdefault(attr, source_attributes[attr])

Expand Down
9 changes: 8 additions & 1 deletion tests/test_signoff_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -904,12 +904,19 @@ def test_the_preview_collection_is_updated_and_signed(self):
def test_the_preview_collection_receives_kinto_admin_ui_attributes(self):
self.app.patch_json(
self.source_collection,
{"data": {"status": "to-review", "displayFields": ["age"]}},
{
"data": {
"status": "to-review",
"displayFields": ["age"],
"schema": {"type": "object"},
}
},
headers=self.headers,
)

resp = self.app.get(self.preview_collection, headers=self.headers)
assert resp.json["data"]["displayFields"] == ["age"]
assert "schema" in resp.json["data"]

def test_the_preview_collection_is_also_resigned(self):
self.app.patch_json(
Expand Down

0 comments on commit 3fd963f

Please sign in to comment.