Skip to content

Commit

Permalink
115427: Fixed delete item not redirecting when having some virtual me…
Browse files Browse the repository at this point in the history
…tadata that needs to be copied
  • Loading branch information
alexandrevryghem committed May 27, 2024
1 parent 249cac4 commit eb9b99c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/app/core/data/base/delete-data.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,19 @@ describe('DeleteDataImpl', () => {
});
});

it('should include the virtual metadata to be copied in the DELETE request', (done) => {
fit('should include the virtual metadata to be copied in the DELETE request', (done) => {
buildFromRequestUUIDAndAwaitSpy.and.returnValue(observableOf(MOCK_SUCCEEDED_RD));

service.deleteByHref('some-href', ['a', 'b', 'c']).subscribe(() => {
expect(requestService.send).toHaveBeenCalledWith(jasmine.objectContaining({
method: RestRequestMethod.DELETE,
href: 'some-href?copyVirtualMetadata=a&copyVirtualMetadata=b&copyVirtualMetadata=c',
}));

const callback = (rdbService.buildFromRequestUUIDAndAwait as jasmine.Spy).calls.argsFor(0)[1];
callback();
expect(service.invalidateByHref).toHaveBeenCalledWith('some-href');

done();
});
});
Expand Down
5 changes: 3 additions & 2 deletions src/app/core/data/base/delete-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,16 @@ export class DeleteDataImpl<T extends CacheableObject> extends IdentifiableDataS
deleteByHref(href: string, copyVirtualMetadata?: string[]): Observable<RemoteData<NoContent>> {
const requestId = this.requestService.generateRequestId();

let deleteHref: string = href;
if (copyVirtualMetadata) {
copyVirtualMetadata.forEach((id) =>
href += (href.includes('?') ? '&' : '?')
deleteHref += (deleteHref.includes('?') ? '&' : '?')
+ 'copyVirtualMetadata='
+ id,
);
}

const request = new DeleteRequest(requestId, href);
const request = new DeleteRequest(requestId, deleteHref);
if (hasValue(this.responseMsToLive)) {
request.responseMsToLive = this.responseMsToLive;
}
Expand Down

0 comments on commit eb9b99c

Please sign in to comment.