Skip to content

Commit

Permalink
[BUGFIX] Fix transaction et updateAt dans le repo organization-for-admin
Browse files Browse the repository at this point in the history
  • Loading branch information
pix-service-auto-merge authored Jun 14, 2024
2 parents ab7e034 + 054056c commit 7a785d7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const findChildrenByParentOrganizationId = async function (parentOrganizationId)
* @return {Promise<OrganizationForAdmin|NotFoundError>}
*/
const get = async function (id, domainTransaction = DomainTransaction.emptyTransaction()) {
const knexConn = domainTransaction.transaction ?? knex;
const knexConn = domainTransaction.knexTransaction ?? knex;
const organization = await knexConn(ORGANIZATIONS_TABLE_NAME)
.select({
id: 'organizations.id',
Expand Down Expand Up @@ -161,7 +161,7 @@ const save = async function (organization) {
* @return {Promise<void>}
*/
const update = async function (organization, domainTransaction = DomainTransaction.emptyTransaction()) {
const knexConn = domainTransaction.transaction ?? knex;
const knexConn = domainTransaction.knexTransaction ?? knex;
const organizationRawData = _.pick(organization, [
'credit',
'documentationUrl',
Expand All @@ -185,7 +185,9 @@ const update = async function (organization, domainTransaction = DomainTransacti
await _addTags(knexConn, organization.tagsToAdd);
await _removeTags(knexConn, organization.tagsToRemove);

await knexConn(ORGANIZATIONS_TABLE_NAME).update(organizationRawData).where({ id: organization.id });
await knexConn(ORGANIZATIONS_TABLE_NAME)
.update({ ...organizationRawData, updatedAt: new Date() })
.where({ id: organization.id });
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ describe('Integration | Organizational Entities | Infrastructure | Repository |
// then
const updatedOrganization = await knex('organizations').where({ id: childOrganization.id }).first();
expect(updatedOrganization.parentOrganizationId).to.equal(parentOrganizationId);
expect(updatedOrganization.updatedAt).to.deep.equal(new Date('2022-02-02'));
});

it('should enable feature', async function () {
Expand Down

0 comments on commit 7a785d7

Please sign in to comment.