Skip to content

Commit

Permalink
Return empty source object for all entity audit events
Browse files Browse the repository at this point in the history
  • Loading branch information
ktuite committed Jan 25, 2024
1 parent df8ab56 commit 3a509b9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/model/query/audits.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ const getByEntityId = (entityId, options) => ({ all }) => {

const details = mergeLeft(audit.details, sourceEvent
.map(event => ({ source: { event, submission } }))
.orElse(undefined));
.orElse({ source: {} })); // Add default empty source to all other entity audit events

return new Audit({ ...audit, details }, { actor: audit.aux.actor });
}));
Expand Down
5 changes: 3 additions & 2 deletions test/integration/api/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,7 @@ describe('Entities API', () => {
logs[1].action.should.be.eql('entity.update.version');
logs[1].details.entity.uuid.should.be.eql('12345678-1234-4123-8234-123456789abc');
logs[1].actor.displayName.should.be.eql('Bob');
logs[1].details.source.should.be.eql({});

logs[2].should.be.an.Audit();
logs[2].action.should.be.eql('entity.create');
Expand Down Expand Up @@ -942,7 +943,7 @@ describe('Entities API', () => {
await asAlice.get('/v1/projects/1/datasets/people/entities/12345678-1234-4123-8234-123456789abc/audits')
.expect(200)
.then(({ body: logs }) => {
logs[0].details.should.not.have.property('source');
logs[0].details.source.should.eql({});
});

await asAlice.patch('/v1/projects/1/datasets/people/entities/12345678-1234-4123-8234-123456789abc?force=true')
Expand All @@ -952,7 +953,7 @@ describe('Entities API', () => {
await asAlice.get('/v1/projects/1/datasets/people/entities/12345678-1234-4123-8234-123456789abc/audits')
.expect(200)
.then(({ body: logs }) => {
logs[0].details.should.not.have.property('source');
logs[0].details.source.should.eql({});
});
}));

Expand Down

0 comments on commit 3a509b9

Please sign in to comment.