From b98d1216b1656d8d60342c0f60a3f20f012cb87e Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Tue, 5 Dec 2017 21:45:43 +0000 Subject: [PATCH] ignore _msgid when merging full objects to hand code and close #1423 --- nodes/core/logic/17-split.js | 2 +- test/nodes/core/logic/17-split_spec.js | 29 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/nodes/core/logic/17-split.js b/nodes/core/logic/17-split.js index ca18b50de..d4fdfc55b 100644 --- a/nodes/core/logic/17-split.js +++ b/nodes/core/logic/17-split.js @@ -441,7 +441,7 @@ module.exports = function(RED) { } } else { for (propertyKey in property) { - if (property.hasOwnProperty(propertyKey)) { + if (property.hasOwnProperty(propertyKey) && propertyKey !== '_msgid') { group.payload[propertyKey] = property[propertyKey]; } } diff --git a/test/nodes/core/logic/17-split_spec.js b/test/nodes/core/logic/17-split_spec.js index 3412d6bc1..db092658e 100644 --- a/test/nodes/core/logic/17-split_spec.js +++ b/test/nodes/core/logic/17-split_spec.js @@ -323,6 +323,7 @@ describe('JOIN node', function() { n1.receive({payload:"D", parts:{id:1, type:"string", ch:",", index:3, count:4}}); }); }); + it('should join bits of buffer back together automatically', function(done) { var flow = [{id:"n1", type:"join", wires:[["n2"]], joiner:",", build:"buffer", mode:"auto"}, {id:"n2", type:"helper"}]; @@ -425,6 +426,34 @@ describe('JOIN node', function() { }); }); + it('should merge full msg objects', function(done) { + var flow = [{id:"n1", type:"join", wires:[["n2"]], count:6, build:"merged", mode:"custom", propertyType:"full", property:""}, + {id:"n2", type:"helper"}]; + helper.load(joinNode, flow, function() { + var n1 = helper.getNode("n1"); + var n2 = helper.getNode("n2"); + n2.on("input", function(msg) { + try { + msg.payload.should.have.property("payload",7); + msg.payload.should.have.property("aha",'c'); + msg.payload.should.have.property("bar",'b'); + msg.payload.should.have.property("bingo",'e'); + msg.payload.should.have.property("foo",'d'); + msg.payload.should.have.property("topic",'a'); + done(); + } + catch(e) { done(e)} + }); + n1.receive({payload:1, topic:"f"}); + n1.receive({payload:2, topic:"a"}); + n1.receive({payload:3, foo:"b"}); + n1.receive({payload:4, bar:"b"}); + n1.receive({payload:5, aha:"c"}); + n1.receive({payload:6, foo:"d"}); + n1.receive({payload:7, bingo:"e"}); + }); + }); + it('should accumulate a merged object', function(done) { var flow = [{id:"n1", type:"join", wires:[["n2"]], build:"merged",mode:"custom",accumulate:true, count:1}, {id:"n2", type:"helper"}];