Commit d1c0b894 authored by Robert Knight's avatar Robert Knight

Merge pull request #2800 from hypothesis/2799-dont-update-wrong-annotations

Don't update annotations with contents of others
parents 9b3ef75c b96d1749
......@@ -343,7 +343,9 @@ function AnnotationController(
}
function onAnnotationUpdated(event, updatedDomainModel) {
updateViewModel(updatedDomainModel, vm, permissions);
if (updatedDomainModel.id === domainModel.id) {
updateViewModel(updatedDomainModel, vm, permissions);
}
}
function onDestroy() {
......
......@@ -1367,6 +1367,33 @@ describe('annotation.js', function() {
});
});
describe('onAnnotationUpdated()', function() {
it('updates vm.form.text', function() {
var parts = createDirective();
var updatedModel = {
id: parts.annotation.id,
text: 'new text',
};
$rootScope.$emit('annotationUpdated', updatedModel);
assert.equal(parts.controller.form.text, 'new text');
});
it('doesn\'t update if a different annotation was updated', function() {
var parts = createDirective();
parts.controller.form.text = 'original text';
var updatedModel = {
id: 'different annotation id',
text: 'new text',
};
$rootScope.$emit('annotationUpdated', updatedModel);
assert.equal(parts.controller.form.text, 'original text');
});
});
describe('onGroupFocused()', function() {
it('if the annotation is being edited it updates drafts', function() {
var parts = createDirective();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment