Skip to content

Commit

Permalink
Merge 7d4cf6c into 2a8b38e
Browse files Browse the repository at this point in the history
  • Loading branch information
juanmahidalgo committed Mar 24, 2022
2 parents 2a8b38e + 7d4cf6c commit 1f15c94
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Item/Item.router.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,23 @@ describe('Item router', () => {
})
})
})

it('should update the item curation with the new content_hash', () => {
return server
.put(buildURL(url))
.send({ item: itemToUpsert })
.set(createAuthHeaders('put', url))
.expect(200)
.then(() => {
expect(ItemCuration.update).toHaveBeenCalledWith(
{
content_hash:
'a630459778465b4882e1cc3e86a019ace033dc06fd2b0d16f4cbab8e075c32f5',
},
{ item_id: dbTPItem.id }
)
})
})
})
})
})
Expand Down
7 changes: 7 additions & 0 deletions src/Item/Item.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,13 @@ export class ItemService {
: null

const upsertedItem: ItemAttributes = await Item.upsert(attributes)
if (dbItem && attributes.local_content_hash) {
// Update the Item Curation content_hash
await ItemCuration.update(
{ content_hash: attributes.local_content_hash },
{ item_id: item.id }
)
}
return Bridge.toFullItem(upsertedItem, dbCollection)
}
}

0 comments on commit 1f15c94

Please sign in to comment.