mirror of
https://github.com/nasa/openmct.git
synced 2025-01-04 20:34:09 +00:00
Save As clears transaction while undirtying (#1471)
* mutation listener adds via transaction manager Update the TransactingMutationListener to add items to a transaction using the transactionManager so that they can be properly removed from the transaction at a later date. Prevents showing error dialogs during successful save, and also prevents persisting duplicate objects. Fixes #1468
This commit is contained in:
parent
e9730ced9e
commit
e5fe8fd975
@ -52,10 +52,7 @@ define([], function () {
|
|||||||
transactionService.startTransaction();
|
transactionService.startTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
transactionService.addToTransaction(
|
persistence.persist();
|
||||||
persistence.persist.bind(persistence),
|
|
||||||
persistence.refresh.bind(persistence)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!wasActive) {
|
if (!wasActive) {
|
||||||
transactionService.commit();
|
transactionService.commit();
|
||||||
|
@ -24,22 +24,27 @@ define(
|
|||||||
["../../src/runs/TransactingMutationListener"],
|
["../../src/runs/TransactingMutationListener"],
|
||||||
function (TransactingMutationListener) {
|
function (TransactingMutationListener) {
|
||||||
|
|
||||||
xdescribe("TransactingMutationListener", function () {
|
describe("TransactingMutationListener", function () {
|
||||||
var mockTopic,
|
var mockTopic,
|
||||||
mockMutationTopic,
|
mockMutationTopic,
|
||||||
|
mockCacheService,
|
||||||
mockTransactionService,
|
mockTransactionService,
|
||||||
mockDomainObject,
|
mockDomainObject,
|
||||||
|
mockModel,
|
||||||
mockPersistence;
|
mockPersistence;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockTopic = jasmine.createSpy('topic');
|
mockTopic = jasmine.createSpy('topic');
|
||||||
mockMutationTopic =
|
mockMutationTopic =
|
||||||
jasmine.createSpyObj('mutation', ['listen']);
|
jasmine.createSpyObj('mutation', ['listen']);
|
||||||
|
mockCacheService =
|
||||||
|
jasmine.createSpyObj('cacheService', [
|
||||||
|
'put'
|
||||||
|
]);
|
||||||
mockTransactionService =
|
mockTransactionService =
|
||||||
jasmine.createSpyObj('transactionService', [
|
jasmine.createSpyObj('transactionService', [
|
||||||
'isActive',
|
'isActive',
|
||||||
'startTransaction',
|
'startTransaction',
|
||||||
'addToTransaction',
|
|
||||||
'commit'
|
'commit'
|
||||||
]);
|
]);
|
||||||
mockDomainObject = jasmine.createSpyObj(
|
mockDomainObject = jasmine.createSpyObj(
|
||||||
@ -52,18 +57,24 @@ define(
|
|||||||
);
|
);
|
||||||
|
|
||||||
mockTopic.and.callFake(function (t) {
|
mockTopic.and.callFake(function (t) {
|
||||||
return (t === 'mutation') && mockMutationTopic;
|
expect(t).toBe('mutation');
|
||||||
|
return mockMutationTopic;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mockDomainObject.getId.and.returnValue('mockId');
|
||||||
mockDomainObject.getCapability.and.callFake(function (c) {
|
mockDomainObject.getCapability.and.callFake(function (c) {
|
||||||
return (c === 'persistence') && mockPersistence;
|
expect(c).toBe('persistence');
|
||||||
|
return mockPersistence;
|
||||||
});
|
});
|
||||||
|
mockModel = {};
|
||||||
|
mockDomainObject.getModel.and.returnValue(mockModel);
|
||||||
|
|
||||||
mockPersistence.persisted.and.returnValue(true);
|
mockPersistence.persisted.and.returnValue(true);
|
||||||
|
|
||||||
return new TransactingMutationListener(
|
return new TransactingMutationListener(
|
||||||
mockTopic,
|
mockTopic,
|
||||||
mockTransactionService
|
mockTransactionService,
|
||||||
|
mockCacheService
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -99,12 +110,8 @@ define(
|
|||||||
).toHaveBeenCalled();
|
).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("adds to the active transaction", function () {
|
it("calls persist", function () {
|
||||||
expect(mockTransactionService.addToTransaction)
|
expect(mockPersistence.persist).toHaveBeenCalled();
|
||||||
.toHaveBeenCalledWith(
|
|
||||||
jasmine.any(Function),
|
|
||||||
jasmine.any(Function)
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it(innerVerb + " immediately commit", function () {
|
it(innerVerb + " immediately commit", function () {
|
||||||
|
Loading…
Reference in New Issue
Block a user