Merge "Handle a resource delete race condition"
This commit is contained in:
commit
245bbd0c06
@ -93,6 +93,10 @@
|
||||
// and failed item.
|
||||
// Currently just refreshes the display each time.
|
||||
if (result) {
|
||||
if (result.failed.length === 0 && result.deleted.length > 0) {
|
||||
// handle a race condition where the resource is already deleted
|
||||
return;
|
||||
}
|
||||
spinnerService.showModalSpinner(gettext('Please Wait'));
|
||||
ctrl.showDetails = false;
|
||||
ctrl.context.loadPromise = ctrl.resourceType.load(ctrl.context.identifier);
|
||||
|
@ -74,7 +74,7 @@
|
||||
|
||||
it('handles empty results', function() {
|
||||
var result = $q.defer();
|
||||
result.resolve({});
|
||||
result.resolve({failed: [], deleted: []});
|
||||
ctrl.resultHandler(result.promise);
|
||||
$timeout.flush();
|
||||
expect(ctrl.showDetails).not.toBe(true);
|
||||
@ -91,13 +91,23 @@
|
||||
it('handles matched results', function() {
|
||||
spyOn(actionResultService, 'getIdsOfType').and.returnValue([1, 2, 3]);
|
||||
var result = $q.defer();
|
||||
result.resolve({some: 'thing'});
|
||||
result.resolve({some: 'thing', failed: [], deleted: []});
|
||||
ctrl.resultHandler(result.promise);
|
||||
deferred.resolve({data: {some: 'data'}});
|
||||
$timeout.flush();
|
||||
expect(ctrl.showDetails).toBe(true);
|
||||
});
|
||||
|
||||
it('handles delete race condition', function() {
|
||||
spyOn(actionResultService, 'getIdsOfType').and.returnValue([1, 2, 3]);
|
||||
var result = $q.defer();
|
||||
result.resolve({some: 'thing', failed: [], deleted: [{id: 1}]});
|
||||
ctrl.resultHandler(result.promise);
|
||||
deferred.resolve({data: {some: 'data'}});
|
||||
$timeout.flush();
|
||||
expect(ctrl.showDetails).toBe(undefined);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -89,6 +89,10 @@
|
||||
// and failed item.
|
||||
// Currently just refreshes the display each time.
|
||||
if (result) {
|
||||
if (result.failed.length === 0 && result.deleted.length > 0) {
|
||||
// handle a race condition where the resource is already deleted
|
||||
return;
|
||||
}
|
||||
spinnerService.showModalSpinner(gettext('Please Wait'));
|
||||
ctrl.showDetails = false;
|
||||
ctrl.context.loadPromise = ctrl.resourceType.load(ctrl.context.identifier);
|
||||
|
@ -70,7 +70,7 @@
|
||||
|
||||
it('handles empty results', function() {
|
||||
var result = $q.defer();
|
||||
result.resolve({});
|
||||
result.resolve({failed: [], deleted: []});
|
||||
ctrl.resultHandler(result.promise);
|
||||
$timeout.flush();
|
||||
expect(ctrl.showDetails).not.toBe(true);
|
||||
@ -87,13 +87,23 @@
|
||||
it('handles matched results', function() {
|
||||
spyOn(actionResultService, 'getIdsOfType').and.returnValue([1, 2, 3]);
|
||||
var result = $q.defer();
|
||||
result.resolve({some: 'thing'});
|
||||
result.resolve({some: 'thing', failed: [], deleted: []});
|
||||
ctrl.resultHandler(result.promise);
|
||||
deferred.resolve({data: {some: 'data'}});
|
||||
$timeout.flush();
|
||||
expect(ctrl.showDetails).toBe(true);
|
||||
});
|
||||
|
||||
it('handles delete race condition', function() {
|
||||
spyOn(actionResultService, 'getIdsOfType').and.returnValue([1, 2, 3]);
|
||||
var result = $q.defer();
|
||||
result.resolve({some: 'thing', failed: [], deleted: [{id: 1}]});
|
||||
ctrl.resultHandler(result.promise);
|
||||
deferred.resolve({data: {some: 'data'}});
|
||||
$timeout.flush();
|
||||
expect(ctrl.showDetails).toBe(undefined);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -85,6 +85,10 @@
|
||||
// and failed item.
|
||||
// Currently just refreshes the display each time.
|
||||
if (result) {
|
||||
if (result.failed.length === 0 && result.deleted.length > 0) {
|
||||
// handle a race condition where the resource is already deleted
|
||||
return;
|
||||
}
|
||||
spinnerService.showModalSpinner(gettext('Please Wait'));
|
||||
ctrl.showDetails = false;
|
||||
ctrl.context.loadPromise = ctrl.resourceType.load(ctrl.context.identifier);
|
||||
|
@ -68,7 +68,7 @@
|
||||
|
||||
it('handles empty results', function() {
|
||||
var result = $q.defer();
|
||||
result.resolve({});
|
||||
result.resolve({failed: [], deleted: []});
|
||||
ctrl.resultHandler(result.promise);
|
||||
$timeout.flush();
|
||||
expect(ctrl.showDetails).not.toBe(true);
|
||||
@ -85,13 +85,23 @@
|
||||
it('handles matched results', function() {
|
||||
spyOn(actionResultService, 'getIdsOfType').and.returnValue([1, 2, 3]);
|
||||
var result = $q.defer();
|
||||
result.resolve({some: 'thing'});
|
||||
result.resolve({some: 'thing', failed: [], deleted: []});
|
||||
ctrl.resultHandler(result.promise);
|
||||
deferred.resolve({data: {some: 'data', floating_ip: {}}});
|
||||
$timeout.flush();
|
||||
expect(ctrl.showDetails).toBe(true);
|
||||
});
|
||||
|
||||
it('handles delete race condition', function() {
|
||||
spyOn(actionResultService, 'getIdsOfType').and.returnValue([1, 2, 3]);
|
||||
var result = $q.defer();
|
||||
result.resolve({some: 'thing', failed: [], deleted: [{id: 1}]});
|
||||
ctrl.resultHandler(result.promise);
|
||||
deferred.resolve({data: {some: 'data'}});
|
||||
$timeout.flush();
|
||||
expect(ctrl.showDetails).toBe(undefined);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -94,6 +94,10 @@
|
||||
// and failed item.
|
||||
// Currently just refreshes the display each time.
|
||||
if (result) {
|
||||
if (result.failed.length === 0 && result.deleted.length > 0) {
|
||||
// handle a race condition where the resource is already deleted
|
||||
return;
|
||||
}
|
||||
spinnerService.showModalSpinner(gettext('Please Wait'));
|
||||
ctrl.showDetails = false;
|
||||
ctrl.context.loadPromise = ctrl.resourceType.load(
|
||||
|
@ -74,7 +74,7 @@
|
||||
|
||||
it('handles empty results', function() {
|
||||
var result = $q.defer();
|
||||
result.resolve({});
|
||||
result.resolve({failed: [], deleted: []});
|
||||
ctrl.resultHandler(result.promise);
|
||||
$timeout.flush();
|
||||
expect(ctrl.showDetails).not.toBe(true);
|
||||
@ -91,13 +91,23 @@
|
||||
it('handles matched results', function() {
|
||||
spyOn(actionResultService, 'getIdsOfType').and.returnValue([1, 2, 3]);
|
||||
var result = $q.defer();
|
||||
result.resolve({some: 'thing'});
|
||||
result.resolve({some: 'thing', failed: [], deleted: []});
|
||||
ctrl.resultHandler(result.promise);
|
||||
deferred.resolve({data: {some: 'data'}});
|
||||
$timeout.flush();
|
||||
expect(ctrl.showDetails).toBe(true);
|
||||
});
|
||||
|
||||
it('handles delete race condition', function() {
|
||||
spyOn(actionResultService, 'getIdsOfType').and.returnValue([1, 2, 3]);
|
||||
var result = $q.defer();
|
||||
result.resolve({some: 'thing', failed: [], deleted: [{id: 1}]});
|
||||
ctrl.resultHandler(result.promise);
|
||||
deferred.resolve({data: {some: 'data'}});
|
||||
$timeout.flush();
|
||||
expect(ctrl.showDetails).toBe(undefined);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -95,6 +95,10 @@
|
||||
// and failed item.
|
||||
// Currently just refreshes the display each time.
|
||||
if (result) {
|
||||
if (result.failed.length === 0 && result.deleted.length > 0) {
|
||||
// handle a race condition where the resource is already deleted
|
||||
return;
|
||||
}
|
||||
spinnerService.showModalSpinner(gettext('Please Wait'));
|
||||
ctrl.showDetails = false;
|
||||
ctrl.context.loadPromise = ctrl.resourceType.load(ctrl.context.identifier);
|
||||
|
@ -72,7 +72,7 @@
|
||||
|
||||
it('handles empty results', function() {
|
||||
var result = $q.defer();
|
||||
result.resolve({});
|
||||
result.resolve({failed: [], deleted: []});
|
||||
ctrl.resultHandler(result.promise);
|
||||
$timeout.flush();
|
||||
expect(ctrl.showDetails).not.toBe(true);
|
||||
@ -89,13 +89,23 @@
|
||||
it('handles matched results', function() {
|
||||
spyOn(actionResultService, 'getIdsOfType').and.returnValue([1, 2, 3]);
|
||||
var result = $q.defer();
|
||||
result.resolve({some: 'thing'});
|
||||
result.resolve({some: 'thing', failed: [], deleted: []});
|
||||
ctrl.resultHandler(result.promise);
|
||||
deferred.resolve({data: {some: 'data'}});
|
||||
$timeout.flush();
|
||||
expect(ctrl.showDetails).toBe(true);
|
||||
});
|
||||
|
||||
it('handles delete race condition', function() {
|
||||
spyOn(actionResultService, 'getIdsOfType').and.returnValue([1, 2, 3]);
|
||||
var result = $q.defer();
|
||||
result.resolve({some: 'thing', failed: [], deleted: [{id: 1}]});
|
||||
ctrl.resultHandler(result.promise);
|
||||
deferred.resolve({data: {some: 'data'}});
|
||||
$timeout.flush();
|
||||
expect(ctrl.showDetails).toBe(undefined);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user