Skip to content

Commit

Permalink
update version in a draft
Browse files Browse the repository at this point in the history
  • Loading branch information
ktuite committed Oct 8, 2024
1 parent e0a1670 commit 3aad326
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/worker/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ const updateEntitiesVersion = async ({ Forms }, event) => {
const draftVersion = await Forms.getByProjectAndXmlFormId(projectId, xmlFormId, true, Form.DraftVersion).then(o => o.orNull());
if (draftVersion && draftVersion.draftDefId != null) {
const partial = await draftVersion.withUpgradeEntityVersion();
// only update xml. maybe it should update the version as well? but this is all happening in place.
await Forms._updateDef(draftVersion.def, { xml: partial.xml });
// update xml and version in place
await Forms._updateDef(draftVersion.def, { xml: partial.xml, version: partial.def.version });
}
};

Expand Down
9 changes: 7 additions & 2 deletions test/integration/other/form-entities-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,15 @@ describe('Update / migrate entities-version within form', () => {
// Run form upgrade
await exhaust(container);

// The version on the draft hasn't changed because it has been updated in place
// The version on the draft does change even though it is updated in place
await asAlice.get('/v1/projects/1/forms/updateEntity/draft')
.then(({ body }) => {
body.version.should.equal('1.0');
body.version.should.equal('1.0_upgrade');
});

await asAlice.get('/v1/projects/1/forms/updateEntity/versions')
.then(({ body }) => {
body.length.should.equal(0);
});

// The XML is updated
Expand Down

0 comments on commit 3aad326

Please sign in to comment.