Merge pull request #727 from nasa/open377

[Search] Index directly on mutation
This commit is contained in:
Andrew Henry 2016-03-11 15:39:43 -08:00
commit abd5913f02
2 changed files with 17 additions and 6 deletions

View File

@ -121,9 +121,13 @@ define([
provider = this;
mutationTopic.listen(function (mutatedObject) {
var id = mutatedObject.getId();
provider.indexedIds[id] = false;
provider.scheduleForIndexing(id);
var status = mutatedObject.getCapability('status');
if (!status || !status.get('editing')) {
provider.index(
mutatedObject.getId(),
mutatedObject.getModel()
);
}
});
};

View File

@ -99,12 +99,19 @@ define([
.toHaveBeenCalledWith(jasmine.any(Function));
});
it('reschedules indexing when mutation occurs', function () {
it('re-indexes when mutation occurs', function () {
var mockDomainObject =
jasmine.createSpyObj('domainObj', ['getId']);
jasmine.createSpyObj('domainObj', [
'getId',
'getModel',
'getCapability'
]),
testModel = { some: 'model' };
mockDomainObject.getId.andReturn("some-id");
mockDomainObject.getModel.andReturn(testModel);
spyOn(provider, 'index').andCallThrough();
mutationTopic.listen.mostRecentCall.args[0](mockDomainObject);
expect(provider.scheduleForIndexing).toHaveBeenCalledWith('some-id');
expect(provider.index).toHaveBeenCalledWith('some-id', testModel);
});
it('starts indexing roots', function () {