From c270aa57f4f5101c0e89a9a1e562fbb56bb93ae9 Mon Sep 17 00:00:00 2001 From: Marshall Thompson Date: Tue, 17 Feb 2015 11:11:40 -0700 Subject: [PATCH 1/2] Fix duplicate events in dynamic services (through setup) --- lib/application.js | 2 +- lib/providers/socket/commons.js | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/application.js b/lib/application.js index 5441d90a22..9a3c92f93b 100644 --- a/lib/application.js +++ b/lib/application.js @@ -47,11 +47,11 @@ module.exports = { // If already _setup, just add this single service. if (this._setup) { + protoService.setup(this, location); // If we're using a socket provider, register the service on it. if (this.addService) { this.addService(protoService, location); } - protoService.setup(this, location); } this.services[location] = protoService; diff --git a/lib/providers/socket/commons.js b/lib/providers/socket/commons.js index 1447dc836e..00d1af53f9 100644 --- a/lib/providers/socket/commons.js +++ b/lib/providers/socket/commons.js @@ -18,7 +18,6 @@ exports.addService = function addService(service, path){ }, this); // Setup events for the service. - eventsMixin.applyEvents.call(service); exports.setupEventHandlers.call(this, service, path); }; From af46b13cd487ec1e05e53f8bc93a760722a577bf Mon Sep 17 00:00:00 2001 From: Marshall Thompson Date: Tue, 17 Feb 2015 11:11:50 -0700 Subject: [PATCH 2/2] Fix event filtering callbacks in tests. --- test/providers/primus.test.js | 11 +++-------- test/providers/socketio.test.js | 11 +++-------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/test/providers/primus.test.js b/test/providers/primus.test.js index abf2401912..6c9631d17a 100644 --- a/test/providers/primus.test.js +++ b/test/providers/primus.test.js @@ -255,7 +255,7 @@ describe('Primus provider', function () { return callback(null, data); } - callback(); + callback(null, false); }; socket.send('todo::remove', 1, {}, function() {}); @@ -432,21 +432,16 @@ describe('Primus provider', function () { return callback(null, data); } - callback(); + callback(null, false); }; socket.send('tasks::remove', 1, {}, function() {}); socket.send('tasks::remove', 23, {}, function() {}); - var ready = false; - socket.on('tasks removed', function (data) { service.removed = oldRemoved; assert.equal(data.id, 23); - if (ready) { - done(); - } - ready = true; + done(); }); }); }); diff --git a/test/providers/socketio.test.js b/test/providers/socketio.test.js index f60085f262..6c7812d87f 100644 --- a/test/providers/socketio.test.js +++ b/test/providers/socketio.test.js @@ -254,7 +254,7 @@ describe('SocketIO provider', function () { return callback(null, data); } - callback(); + callback(null, false); }; socket.emit('todo::remove', 1, {}, function() {}); @@ -431,21 +431,16 @@ describe('SocketIO provider', function () { return callback(null, data); } - callback(); + callback(null, false); }; socket.emit('tasks::remove', 1, {}, function() {}); socket.emit('tasks::remove', 23, {}, function() {}); - var ready = false; - socket.on('tasks removed', function (data) { service.removed = oldRemoved; assert.equal(data.id, 23); - if (ready) { - done(); - } - ready = true; + done(); }); }); });