1
0

fix issue where submission requests would time out before they could be used once

This commit is contained in:
Art Lowel
2019-11-29 15:15:06 +01:00
parent afa61b11c8
commit 0048a97181
2 changed files with 4 additions and 6 deletions

View File

@@ -59,12 +59,11 @@ describe('SubmissionRestService test suite', () => {
describe('getDataById', () => { describe('getDataById', () => {
it('should configure a new SubmissionRequest', () => { it('should configure a new SubmissionRequest', () => {
const expected = new SubmissionRequest(requestService.generateRequestId(), resourceHref); const expected = new SubmissionRequest(requestService.generateRequestId(), resourceHref);
// set cache time to zero
expected.responseMsToLive = 0;
expected.forceBypassCache = true; expected.forceBypassCache = true;
scheduler.schedule(() => service.getDataById(resourceEndpoint, resourceScope).subscribe()); scheduler.schedule(() => service.getDataById(resourceEndpoint, resourceScope).subscribe());
scheduler.flush(); scheduler.flush();
expect(requestService.removeByHrefSubstring).toHaveBeenCalledWith(resourceHref);
expect(requestService.configure).toHaveBeenCalledWith(expected); expect(requestService.configure).toHaveBeenCalledWith(expected);
}); });
}); });

View File

@@ -109,11 +109,10 @@ export class SubmissionRestService {
filter((href: string) => isNotEmpty(href)), filter((href: string) => isNotEmpty(href)),
distinctUntilChanged(), distinctUntilChanged(),
map((endpointURL: string) => new SubmissionRequest(requestId, endpointURL)), map((endpointURL: string) => new SubmissionRequest(requestId, endpointURL)),
map ((request: RestRequest) => { tap((request: RestRequest) => {
request.responseMsToLive = 0; this.requestService.removeByHrefSubstring(request.href);
return request; this.requestService.configure(request);
}), }),
tap((request: RestRequest) => this.requestService.configure(request)),
flatMap(() => this.fetchRequest(requestId)), flatMap(() => this.fetchRequest(requestId)),
distinctUntilChanged()); distinctUntilChanged());
} }