From ce6e11a8a02a5d3f209208b498ad79c0c4984364 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Fri, 18 Jan 2013 10:35:15 -0800 Subject: [PATCH] Test copying tags to the split way --- js/id/actions/split_way.js | 9 ++++----- js/id/modes/select.js | 2 +- test/spec/actions/split_way.js | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/js/id/actions/split_way.js b/js/id/actions/split_way.js index 6682ab638..fe73eeb55 100644 --- a/js/id/actions/split_way.js +++ b/js/id/actions/split_way.js @@ -7,17 +7,16 @@ iD.actions.SplitWay = function(nodeId) { // splitting ways at intersections TODO if (parents.length !== 1) return graph; - var way = parents[0]; - - var idx = _.indexOf(way.nodes, nodeId); + var way = parents[0], + idx = _.indexOf(way.nodes, nodeId); // Create a 'b' way that contains all of the tags in the second // half of this way - var newWay = iD.Way({ tags: _.clone(way.tags), nodes: way.nodes.slice(idx) }); + var newWay = iD.Way({tags: way.tags, nodes: way.nodes.slice(idx)}); graph = graph.replace(newWay); // Reduce the original way to only contain the first set of nodes - graph = graph.replace(way.update({ nodes: way.nodes.slice(0, idx + 1) }), 'changed way direction'); + graph = graph.replace(way.update({nodes: way.nodes.slice(0, idx + 1)})); var parentRelations = graph.parentRelations(way); diff --git a/js/id/modes/select.js b/js/id/modes/select.js index 62b309e29..8d59fbe43 100644 --- a/js/id/modes/select.js +++ b/js/id/modes/select.js @@ -75,7 +75,7 @@ iD.modes.Select = function (entity) { }).on('splitWay', function(d) { mode.history.perform( iD.actions.SplitWay(d.id), - 'split a way on a node'); + 'split a way'); }).on('remove', function() { remove(); diff --git a/test/spec/actions/split_way.js b/test/spec/actions/split_way.js index 6a4edc187..420fdba14 100644 --- a/test/spec/actions/split_way.js +++ b/test/spec/actions/split_way.js @@ -28,6 +28,20 @@ describe("iD.actions.SplitWay", function () { expect(waysB[1]).to.equal(waysC[0]); }); + it("copies tags to the new way", function () { + var a = iD.Node(), + b = iD.Node(), + c = iD.Node(), + tags = {highway: 'residential'}, + way = iD.Way({nodes: [a.id, b.id, c.id], tags: tags}), + graph = iD.Graph([a, b, c, way]); + + graph = iD.actions.SplitWay(b.id)(graph); + + expect(graph.parentWays(a)[0].tags).to.eql(tags); + expect(graph.parentWays(c)[0].tags).to.eql(tags); + }); + it("moves restriction relations to the new way", function () { // Situation: // a ==== b ==== c ---- d