mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
111326: return not found status code on missing identifiers
This commit is contained in:

committed by
Tim Donohue

parent
57c2b02277
commit
92f2a77dae
@@ -6,6 +6,7 @@ import { ObjectNotFoundComponent } from './objectnotfound.component';
|
|||||||
import { ActivatedRouteStub } from '../../shared/testing/active-router.stub';
|
import { ActivatedRouteStub } from '../../shared/testing/active-router.stub';
|
||||||
import { of as observableOf } from 'rxjs';
|
import { of as observableOf } from 'rxjs';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
import { ServerResponseService } from 'src/app/core/services/server-response.service';
|
||||||
|
|
||||||
describe('ObjectNotFoundComponent', () => {
|
describe('ObjectNotFoundComponent', () => {
|
||||||
let comp: ObjectNotFoundComponent;
|
let comp: ObjectNotFoundComponent;
|
||||||
@@ -17,6 +18,10 @@ describe('ObjectNotFoundComponent', () => {
|
|||||||
const activatedRouteStub = Object.assign(new ActivatedRouteStub(), {
|
const activatedRouteStub = Object.assign(new ActivatedRouteStub(), {
|
||||||
params: observableOf({id: testUUID, idType: uuidType})
|
params: observableOf({id: testUUID, idType: uuidType})
|
||||||
});
|
});
|
||||||
|
const serverResponseServiceStub = jasmine.createSpyObj('ServerResponseService', {
|
||||||
|
setNotFound: jasmine.createSpy('setNotFound')
|
||||||
|
});
|
||||||
|
|
||||||
const activatedRouteStubHandle = Object.assign(new ActivatedRouteStub(), {
|
const activatedRouteStubHandle = Object.assign(new ActivatedRouteStub(), {
|
||||||
params: observableOf({id: handleId, idType: handlePrefix})
|
params: observableOf({id: handleId, idType: handlePrefix})
|
||||||
});
|
});
|
||||||
@@ -26,6 +31,7 @@ describe('ObjectNotFoundComponent', () => {
|
|||||||
imports: [
|
imports: [
|
||||||
TranslateModule.forRoot()
|
TranslateModule.forRoot()
|
||||||
], providers: [
|
], providers: [
|
||||||
|
{provide: ServerResponseService, useValue: serverResponseServiceStub},
|
||||||
{provide: ActivatedRoute, useValue: activatedRouteStub}
|
{provide: ActivatedRoute, useValue: activatedRouteStub}
|
||||||
],
|
],
|
||||||
declarations: [ObjectNotFoundComponent],
|
declarations: [ObjectNotFoundComponent],
|
||||||
@@ -48,6 +54,10 @@ describe('ObjectNotFoundComponent', () => {
|
|||||||
expect(comp.idType).toEqual(uuidType);
|
expect(comp.idType).toEqual(uuidType);
|
||||||
expect(comp.missingItem).toEqual('uuid: ' + testUUID);
|
expect(comp.missingItem).toEqual('uuid: ' + testUUID);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should call serverResponseService.setNotFound', () => {
|
||||||
|
expect(serverResponseServiceStub.setNotFound).toHaveBeenCalled();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe( 'legacy handle request', () => {
|
describe( 'legacy handle request', () => {
|
||||||
@@ -56,6 +66,7 @@ describe('ObjectNotFoundComponent', () => {
|
|||||||
imports: [
|
imports: [
|
||||||
TranslateModule.forRoot()
|
TranslateModule.forRoot()
|
||||||
], providers: [
|
], providers: [
|
||||||
|
{provide: ServerResponseService, useValue: serverResponseServiceStub},
|
||||||
{provide: ActivatedRoute, useValue: activatedRouteStubHandle}
|
{provide: ActivatedRoute, useValue: activatedRouteStubHandle}
|
||||||
],
|
],
|
||||||
declarations: [ObjectNotFoundComponent],
|
declarations: [ObjectNotFoundComponent],
|
||||||
@@ -74,6 +85,9 @@ describe('ObjectNotFoundComponent', () => {
|
|||||||
expect(comp.idType).toEqual(handlePrefix);
|
expect(comp.idType).toEqual(handlePrefix);
|
||||||
expect(comp.missingItem).toEqual('handle: ' + handlePrefix + '/' + handleId);
|
expect(comp.missingItem).toEqual('handle: ' + handlePrefix + '/' + handleId);
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
|
it('should call serverResponseService.setNotFound', () => {
|
||||||
|
expect(serverResponseServiceStub.setNotFound).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
import { Component, ChangeDetectionStrategy, OnInit } from '@angular/core';
|
import { Component, ChangeDetectionStrategy, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
import { ServerResponseService } from 'src/app/core/services/server-response.service';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This component representing the `PageNotFound` DSpace page.
|
* This component representing the `PageNotFound` DSpace page.
|
||||||
@@ -25,7 +26,7 @@ export class ObjectNotFoundComponent implements OnInit {
|
|||||||
* @param {AuthService} authservice
|
* @param {AuthService} authservice
|
||||||
* @param {ServerResponseService} responseService
|
* @param {ServerResponseService} responseService
|
||||||
*/
|
*/
|
||||||
constructor(private route: ActivatedRoute) {
|
constructor(private route: ActivatedRoute, private serverResponseService: ServerResponseService) {
|
||||||
route.params.subscribe((params) => {
|
route.params.subscribe((params) => {
|
||||||
this.idType = params.idType;
|
this.idType = params.idType;
|
||||||
this.id = params.id;
|
this.id = params.id;
|
||||||
@@ -38,6 +39,7 @@ export class ObjectNotFoundComponent implements OnInit {
|
|||||||
} else {
|
} else {
|
||||||
this.missingItem = 'handle: ' + this.idType + '/' + this.id;
|
this.missingItem = 'handle: ' + this.idType + '/' + this.id;
|
||||||
}
|
}
|
||||||
|
this.serverResponseService.setNotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user