mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
move embed item fix to SubmissionJsonPatchOperationsService
This commit is contained in:
@@ -156,7 +156,7 @@ describe('JsonPatchOperationsService test suite', () => {
|
||||
});
|
||||
|
||||
it('should send a new SubmissionPatchRequest', () => {
|
||||
const expected = new SubmissionPatchRequest(requestService.generateRequestId(), resourceHref + '?embed=item', patchOpBody);
|
||||
const expected = new SubmissionPatchRequest(requestService.generateRequestId(), resourceHref, patchOpBody);
|
||||
scheduler.schedule(() => service.jsonPatchByResourceType(resourceEndpoint, resourceScope, testJsonPatchResourceType).subscribe());
|
||||
scheduler.flush();
|
||||
|
||||
@@ -246,7 +246,7 @@ describe('JsonPatchOperationsService test suite', () => {
|
||||
});
|
||||
|
||||
it('should send a new SubmissionPatchRequest', () => {
|
||||
const expected = new SubmissionPatchRequest(requestService.generateRequestId(), resourceHref + '?embed=item', patchOpBody);
|
||||
const expected = new SubmissionPatchRequest(requestService.generateRequestId(), resourceHref, patchOpBody);
|
||||
scheduler.schedule(() => service.jsonPatchByResourceID(resourceEndpoint, resourceScope, testJsonPatchResourceType, testJsonPatchResourceId).subscribe());
|
||||
scheduler.flush();
|
||||
|
||||
|
@@ -28,7 +28,6 @@ import { PatchRequest } from '../data/request.models';
|
||||
import { RequestService } from '../data/request.service';
|
||||
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
||||
import { getFirstCompletedRemoteData } from '../shared/operators';
|
||||
import { URLCombiner } from '../url-combiner/url-combiner';
|
||||
import { JsonPatchOperationModel } from './json-patch.model';
|
||||
import {
|
||||
CommitPatchOperationsAction,
|
||||
@@ -145,7 +144,7 @@ export abstract class JsonPatchOperationsService<ResponseDefinitionDomain, Patch
|
||||
* instance of PatchRequestDefinition
|
||||
*/
|
||||
protected getRequestInstance(uuid: string, href: string, body?: any): PatchRequestDefinition {
|
||||
return new this.patchRequestConstructor(uuid, new URLCombiner(href, '?embed=item').toString(), body);
|
||||
return new this.patchRequestConstructor(uuid, href, body);
|
||||
}
|
||||
|
||||
protected getEndpointByIDHref(endpoint, resourceID): string {
|
||||
|
@@ -17,6 +17,9 @@ describe('SubmissionJsonPatchOperationsService', () => {
|
||||
const rdbService = {} as RemoteDataBuildService;
|
||||
const halEndpointService = {} as HALEndpointService;
|
||||
|
||||
const uuid = '91ecbeda-99fe-42ac-9430-b9b75af56f78';
|
||||
const href = 'https://rest.api/some/self/link?with=maybe&a=few&other=parameters';
|
||||
|
||||
function initTestService() {
|
||||
return new SubmissionJsonPatchOperationsService(
|
||||
requestService,
|
||||
@@ -36,4 +39,16 @@ describe('SubmissionJsonPatchOperationsService', () => {
|
||||
expect((service as any).patchRequestConstructor).toEqual(SubmissionPatchRequest);
|
||||
});
|
||||
|
||||
describe(`getRequestInstance`, () => {
|
||||
it(`should add a parameter to embed the item to the request URL`, () => {
|
||||
const result = (service as any).getRequestInstance(uuid, href);
|
||||
const resultURL = new URL(result.href);
|
||||
expect(resultURL.searchParams.get('embed')).toEqual('item');
|
||||
|
||||
// if we delete the embed item param, it should be identical to the original url
|
||||
resultURL.searchParams.delete('embed', 'item');
|
||||
expect(href).toEqual(resultURL.toString());
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
@@ -8,6 +8,7 @@ import { RequestService } from '../data/request.service';
|
||||
import { JsonPatchOperationsService } from '../json-patch/json-patch-operations.service';
|
||||
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
||||
import { SubmitDataResponseDefinitionObject } from '../shared/submit-data-response-definition.model';
|
||||
import { URLCombiner } from '../url-combiner/url-combiner';
|
||||
|
||||
/**
|
||||
* A service that provides methods to make JSON Patch requests.
|
||||
@@ -26,4 +27,20 @@ export class SubmissionJsonPatchOperationsService extends JsonPatchOperationsSer
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an instance for RestRequest class
|
||||
*
|
||||
* @param uuid
|
||||
* The request uuid
|
||||
* @param href
|
||||
* The request href
|
||||
* @param body
|
||||
* The request body
|
||||
* @return Object<PatchRequestDefinition>
|
||||
* instance of PatchRequestDefinition
|
||||
*/
|
||||
protected getRequestInstance(uuid: string, href: string, body?: any): SubmissionPatchRequest {
|
||||
return new this.patchRequestConstructor(uuid, new URLCombiner(href, '?embed=item').toString(), body);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user