Skip to content

Commit

Permalink
Merge pull request #490 from samwel141/fix
Browse files Browse the repository at this point in the history
fix updated_at on trust relationship state change
  • Loading branch information
Kpoke authored Oct 29, 2024
2 parents 8be531f + a7ea273 commit 60052f4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions server/models/Trust.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,14 @@ class Trust {

async updateTrustState(trustRelationship, state) {
const trustRelationshipToUpdate = { ...trustRelationship };
const now = new Date();
const formattedDate = `${(now.getMonth() + 1).toString().padStart(2, '0')}/${now
.getDate()
.toString()
.padStart(2, '0')}/${now.getFullYear()}`;

trustRelationshipToUpdate.state = state;
trustRelationshipToUpdate.updated_at = formattedDate;
delete trustRelationshipToUpdate.originating_wallet;
delete trustRelationshipToUpdate.actor_wallet;
delete trustRelationshipToUpdate.target_wallet;
Expand Down
8 changes: 8 additions & 0 deletions server/models/Trust.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,13 @@ describe('Trust Model', () => {
it('updateTrustState', async () => {
trustRepositoryStub.update.resolves({ status: 'updated' });

const now = new Date();
const formattedDate = `${(now.getMonth() + 1).toString().padStart(2, '0')}/${now
.getDate()
.toString()
.padStart(2, '0')}/${now.getFullYear()}`;


const result = await trustModel.updateTrustState(
{
id: 'trustId',
Expand All @@ -760,6 +767,7 @@ describe('Trust Model', () => {
expect(trustRepositoryStub.update).calledOnceWithExactly({
id: 'trustId',
state: 'new state',
updated_at: formattedDate
});
});

Expand Down

0 comments on commit 60052f4

Please sign in to comment.