Don't allow deleting incomplete relations

This will fail with an "entity not found" error.
This commit is contained in:
John Firebaugh
2013-05-16 16:43:41 -07:00
parent 1cfeba3da4
commit da9602795c
9 changed files with 69 additions and 15 deletions
+10
View File
@@ -18,4 +18,14 @@ describe("iD.actions.DeleteMultiple", function () {
expect(graph.hasEntity(w.id)).to.be.undefined;
expect(graph.hasEntity(n.id)).to.be.undefined;
});
describe("#disabled", function () {
it("returns the result of the first action that is disabled", function () {
var node = iD.Node(),
relation = iD.Relation({members: [{id: 'w'}]}),
graph = iD.Graph([node, relation]),
action = iD.actions.DeleteMultiple([node.id, relation.id]);
expect(action.disabled(graph)).to.equal('incomplete_relation');
});
});
});
+9
View File
@@ -73,4 +73,13 @@ describe("iD.actions.DeleteRelation", function () {
graph = action(iD.Graph([node, way, relation]));
expect(graph.hasEntity(node.id)).to.be.undefined;
});
describe("#disabled", function() {
it("returns 'incomplete_relation' if the relation is incomplete", function() {
var relation = iD.Relation({members: [{id: 'w'}]}),
graph = iD.Graph([relation]),
action = iD.actions.DeleteRelation(relation.id);
expect(action.disabled(graph)).to.equal('incomplete_relation');
});
});
});