Merge "Added safety check to initActions so unregistered types pass"

This commit is contained in:
Jenkins 2016-06-14 03:18:56 +00:00 committed by Gerrit Code Review
commit 947b9f5b42
2 changed files with 13 additions and 4 deletions

View File

@ -602,10 +602,13 @@
* for the given type. This requires the proper scope be passed.
* If an action does not have an initScope() function, it is ignored.
*/
function initActions(type, scope) {
angular.forEach(resourceTypes[type].itemActions, setActionScope);
angular.forEach(resourceTypes[type].batchActions, setActionScope);
angular.forEach(resourceTypes[type].globalActions, setActionScope);
function initActions(typeName, scope) {
var type = resourceTypes[typeName];
if (type) {
angular.forEach(type.itemActions, setActionScope);
angular.forEach(type.batchActions, setActionScope);
angular.forEach(type.globalActions, setActionScope);
}
function setActionScope(action) {
if (action.service.initScope) {

View File

@ -54,6 +54,12 @@
expect(returned).toBeUndefined();
});
it('init ignores initScope when not type is not present', function() {
var returned = service.initActions('was-never-registered', {} );
// but we got here
expect(returned).toBeUndefined();
});
describe('getResourceType', function() {
it('returns a new resource type object even without a config', function() {
var value = service.getResourceType('something');