Merge "Added safety check to initActions so unregistered types pass"
This commit is contained in:
commit
947b9f5b42
@ -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) {
|
||||
|
@ -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');
|
||||
|
Loading…
Reference in New Issue
Block a user