mirror of
https://github.com/nasa/openmct.git
synced 2025-06-19 07:38:15 +00:00
[persistence] fix for issue #1593
prevent EditorCapability#finish from calling transactionservice#cancel when transactionService was not active - leading to console error everytime user would leave edit mode Add tests for changes made and also to check for return type in either case (isActive or not)
This commit is contained in:
@ -101,10 +101,15 @@ define(
|
|||||||
*/
|
*/
|
||||||
EditorCapability.prototype.finish = function () {
|
EditorCapability.prototype.finish = function () {
|
||||||
var domainObject = this.domainObject;
|
var domainObject = this.domainObject;
|
||||||
return this.transactionService.cancel().then(function () {
|
|
||||||
domainObject.getCapability("status").set("editing", false);
|
if (this.transactionService.isActive()) {
|
||||||
return domainObject;
|
return this.transactionService.cancel().then(function () {
|
||||||
});
|
domainObject.getCapability("status").set("editing", false);
|
||||||
|
return domainObject;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return Promise.resolve(domainObject);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -62,6 +62,7 @@ define(
|
|||||||
);
|
);
|
||||||
mockTransactionService.commit.andReturn(fastPromise());
|
mockTransactionService.commit.andReturn(fastPromise());
|
||||||
mockTransactionService.cancel.andReturn(fastPromise());
|
mockTransactionService.cancel.andReturn(fastPromise());
|
||||||
|
mockTransactionService.isActive = jasmine.createSpy('isActive');
|
||||||
|
|
||||||
mockStatusCapability = jasmine.createSpyObj(
|
mockStatusCapability = jasmine.createSpyObj(
|
||||||
"statusCapability",
|
"statusCapability",
|
||||||
@ -141,6 +142,7 @@ define(
|
|||||||
|
|
||||||
describe("finish", function () {
|
describe("finish", function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
mockTransactionService.isActive.andReturn(true);
|
||||||
capability.edit();
|
capability.edit();
|
||||||
capability.finish();
|
capability.finish();
|
||||||
});
|
});
|
||||||
@ -152,6 +154,23 @@ define(
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("finish", function () {
|
||||||
|
beforeEach(function () {
|
||||||
|
mockTransactionService.isActive.andReturn(false);
|
||||||
|
capability.edit();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("does not cancel transaction when transaction is not active", function () {
|
||||||
|
capability.finish();
|
||||||
|
expect(mockTransactionService.cancel).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("returns a promise", function () {
|
||||||
|
expect(capability.finish() instanceof Promise).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
describe("dirty", function () {
|
describe("dirty", function () {
|
||||||
var model = {};
|
var model = {};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user