Use initAction instead initScope

initScope() is deprecated in Ocata and will be removed in Queens.
So this patch changes to use initScope() to initAction().

Change-Id: I66af8b65824d224cb69004557df9f7aaf50afc72
Closes-Bug: #1647921
This commit is contained in:
Shu Muto 2016-12-07 15:34:59 +09:00
parent 72435b52f7
commit 538e0104ac
12 changed files with 39 additions and 39 deletions

View File

@ -50,7 +50,7 @@
}; };
var service = { var service = {
initScope: initScope, initAction: initAction,
perform: perform, perform: perform,
allowed: allowed allowed: allowed
}; };
@ -59,15 +59,15 @@
////////////// //////////////
function initScope($scope) { function initAction() {
}
function perform(selected, $scope) {
scope = $scope; scope = $scope;
scope.workflow = createWorkflow; scope.workflow = createWorkflow;
scope.model = model; scope.model = model;
scope.$on('$destroy', function() { scope.$on('$destroy', function() {
}); });
}
function perform() {
scope.model.init(); scope.model.init();
return wizardModalService.modal({ return wizardModalService.modal({
scope: scope, scope: scope,

View File

@ -56,8 +56,8 @@
it('open the modal and should destroy event watchers', function() { it('open the modal and should destroy event watchers', function() {
spyOn(wizardModalService, 'modal').and.callThrough(); spyOn(wizardModalService, 'modal').and.callThrough();
service.initScope($scope); service.initAction();
service.perform(); service.perform(null, $scope);
$scope.$emit('$destroy'); $scope.$emit('$destroy');
@ -74,8 +74,8 @@
spyOn(wizardModalService, 'modal').and.callThrough(); spyOn(wizardModalService, 'modal').and.callThrough();
service.initScope($scope); service.initAction();
service.perform(); service.perform(null, $scope);
var modalArgs = wizardModalService.modal.calls.argsFor(0)[0]; var modalArgs = wizardModalService.modal.calls.argsFor(0)[0];
modalArgs.submit(); modalArgs.submit();
$timeout.flush(); $timeout.flush();

View File

@ -64,7 +64,7 @@
successEvent: events.DELETE_SUCCESS successEvent: events.DELETE_SUCCESS
}; };
var service = { var service = {
initScope: initScope, initAction: initAction,
allowed: allowed, allowed: allowed,
perform: perform perform: perform
}; };
@ -76,8 +76,7 @@
// include this function in your service // include this function in your service
// if you plan to emit events to the parent controller // if you plan to emit events to the parent controller
function initScope($scope) { function initAction() {
scope = $scope;
} }
function allowed() { function allowed() {
@ -85,7 +84,8 @@
} }
// delete selected resource objects // delete selected resource objects
function perform(selected) { function perform(selected, $scope) {
scope = $scope;
selected = angular.isArray(selected) ? selected : [selected]; selected = angular.isArray(selected) ? selected : [selected];
context.labels = labelize(selected.length); context.labels = labelize(selected.length);
return $qExtensions.allSettled(selected.map(checkPermission)).then(afterCheck); return $qExtensions.allSettled(selected.map(checkPermission)).then(afterCheck);

View File

@ -90,7 +90,7 @@
beforeEach(function() { beforeEach(function() {
spyOn(deleteModalService, 'open').and.callThrough(); spyOn(deleteModalService, 'open').and.callThrough();
service.initScope($scope, labelize); service.initAction(labelize);
}); });
function labelize(count) { function labelize(count) {
@ -117,7 +117,7 @@
function testDoubleObject() { function testDoubleObject() {
var templates = generateTemplate(2); var templates = generateTemplate(2);
service.perform(templates); service.perform(templates, $scope);
$scope.$apply(); $scope.$apply();
expect(deleteModalService.open).toHaveBeenCalled(); expect(deleteModalService.open).toHaveBeenCalled();
@ -129,7 +129,7 @@
spyOn(magnumAPI, 'deleteEntity'); spyOn(magnumAPI, 'deleteEntity');
var templates = generateTemplate(1); var templates = generateTemplate(1);
var template = templates[0]; var template = templates[0];
service.perform(templates); service.perform(templates, $scope);
$scope.$apply(); $scope.$apply();
var contextArg = deleteModalService.open.calls.argsFor(0)[2]; var contextArg = deleteModalService.open.calls.argsFor(0)[2];

View File

@ -49,7 +49,7 @@
}; };
var service = { var service = {
initScope: initScope, initAction: initAction,
perform: perform, perform: perform,
allowed: allowed allowed: allowed
}; };
@ -58,15 +58,15 @@
////////////// //////////////
function initScope($scope) { function initAction() {
}
function perform(selected, $scope) {
scope = $scope; scope = $scope;
scope.workflow = createWorkflow; scope.workflow = createWorkflow;
scope.model = model; scope.model = model;
scope.$on('$destroy', function() { scope.$on('$destroy', function() {
}); });
}
function perform(selected) {
scope.model.init(); scope.model.init();
scope.selected = selected; scope.selected = selected;
return wizardModalService.modal({ return wizardModalService.modal({

View File

@ -56,8 +56,8 @@
it('open the modal and should destroy event watchers', function() { it('open the modal and should destroy event watchers', function() {
spyOn(wizardModalService, 'modal').and.callThrough(); spyOn(wizardModalService, 'modal').and.callThrough();
service.initScope($scope); service.initAction();
service.perform(); service.perform(null, $scope);
$scope.$emit('$destroy'); $scope.$emit('$destroy');
@ -74,8 +74,8 @@
spyOn(wizardModalService, 'modal').and.callThrough(); spyOn(wizardModalService, 'modal').and.callThrough();
service.initScope($scope); service.initAction();
service.perform(); service.perform(null, $scope);
var modalArgs = wizardModalService.modal.calls.argsFor(0)[0]; var modalArgs = wizardModalService.modal.calls.argsFor(0)[0];
modalArgs.submit(); modalArgs.submit();
$timeout.flush(); $timeout.flush();

View File

@ -64,7 +64,7 @@
successEvent: events.DELETE_SUCCESS successEvent: events.DELETE_SUCCESS
}; };
var service = { var service = {
initScope: initScope, initAction: initAction,
allowed: allowed, allowed: allowed,
perform: perform perform: perform
}; };
@ -76,8 +76,7 @@
// include this function in your service // include this function in your service
// if you plan to emit events to the parent controller // if you plan to emit events to the parent controller
function initScope($scope) { function initAction() {
scope = $scope;
} }
function allowed() { function allowed() {
@ -85,7 +84,8 @@
} }
// delete selected resource objects // delete selected resource objects
function perform(selected) { function perform(selected, $scope) {
scope = $scope;
selected = angular.isArray(selected) ? selected : [selected]; selected = angular.isArray(selected) ? selected : [selected];
context.labels = labelize(selected.length); context.labels = labelize(selected.length);
return $qExtensions.allSettled(selected.map(checkPermission)).then(afterCheck); return $qExtensions.allSettled(selected.map(checkPermission)).then(afterCheck);

View File

@ -90,7 +90,7 @@
beforeEach(function() { beforeEach(function() {
spyOn(deleteModalService, 'open').and.callThrough(); spyOn(deleteModalService, 'open').and.callThrough();
service.initScope($scope, labelize); service.initAction(labelize);
}); });
function labelize(count) { function labelize(count) {
@ -107,7 +107,7 @@
function testSingleObject() { function testSingleObject() {
var clusters = generateCluster(1); var clusters = generateCluster(1);
service.perform(clusters[0]); service.perform(clusters[0], $scope);
$scope.$apply(); $scope.$apply();
expect(deleteModalService.open).toHaveBeenCalled(); expect(deleteModalService.open).toHaveBeenCalled();
@ -117,7 +117,7 @@
function testDoubleObject() { function testDoubleObject() {
var clusters = generateCluster(2); var clusters = generateCluster(2);
service.perform(clusters); service.perform(clusters, $scope);
$scope.$apply(); $scope.$apply();
expect(deleteModalService.open).toHaveBeenCalled(); expect(deleteModalService.open).toHaveBeenCalled();
@ -129,7 +129,7 @@
spyOn(magnumAPI, 'deleteEntity'); spyOn(magnumAPI, 'deleteEntity');
var clusters = generateCluster(1); var clusters = generateCluster(1);
var cluster = clusters[0]; var cluster = clusters[0];
service.perform(clusters); service.perform(clusters, $scope);
$scope.$apply(); $scope.$apply();
var contextArg = deleteModalService.open.calls.argsFor(0)[2]; var contextArg = deleteModalService.open.calls.argsFor(0)[2];

View File

@ -36,7 +36,7 @@
) { ) {
var service = { var service = {
initScope: initScope, initAction: initAction,
perform: perform, perform: perform,
allowed: allowed allowed: allowed
}; };
@ -45,7 +45,7 @@
////////////// //////////////
function initScope() { function initAction() {
} }
function perform(selected) { function perform(selected) {

View File

@ -45,7 +45,7 @@
selected = { selected = {
id: '1' id: '1'
}; };
service.initScope(); service.initAction();
service.perform(selected); service.perform(selected);
expect(magnum.showCertificate).toHaveBeenCalled(); expect(magnum.showCertificate).toHaveBeenCalled();
}); });

View File

@ -47,7 +47,7 @@
}; };
var service = { var service = {
initScope: initScope, initAction: initAction,
perform: perform, perform: perform,
allowed: allowed allowed: allowed
}; };
@ -56,7 +56,7 @@
////////////// //////////////
function initScope() { function initAction() {
} }
function signCertificateModal(html, $modal) { function signCertificateModal(html, $modal) {

View File

@ -65,7 +65,7 @@
it('should pass submit() and success()', inject(function($timeout) { it('should pass submit() and success()', inject(function($timeout) {
var selected = {id : 1}; var selected = {id : 1};
service.initScope(); service.initAction();
service.perform(selected); service.perform(selected);
$timeout.flush(); $timeout.flush();