From fa8ac8d324c65b0d1441a817b34c2458276b43c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Fri, 29 Jul 2016 16:49:29 +0200 Subject: [PATCH] Backport of #2565 --- test/remote-connector.test.js | 23 +++++++++++++++++------ test/util/model-tests.js | 3 ++- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/test/remote-connector.test.js b/test/remote-connector.test.js index 701e170b..88023ddd 100644 --- a/test/remote-connector.test.js +++ b/test/remote-connector.test.js @@ -25,14 +25,25 @@ describe('RemoteConnector', function() { done(); }); }, + + // We are defining the model attached to the remote connector datasource, + // therefore change tracking must be disabled, only the remote API for + // replication should be present + trackChanges: false, + enableRemoteReplication: true, + onDefine: function(Model) { - var RemoteModel = Model.extend('Remote' + Model.modelName, {}, - { plural: Model.pluralModelName }); - RemoteModel.attachTo(loopback.createDataSource({ - connector: loopback.Memory + var ServerModel = Model.extend('Server' + Model.modelName, {}, { + plural: Model.pluralModelName, + // This is the model running on the server & attached to a real + // datasource, that's the place where to keep track of changes + trackChanges: true, + }); + ServerModel.attachTo(loopback.createDataSource({ + connector: loopback.Memory, })); - remoteApp.model(RemoteModel); - } + remoteApp.model(ServerModel); + }, }); beforeEach(function(done) { diff --git a/test/util/model-tests.js b/test/util/model-tests.js index d554c2d4..cac6ffca 100644 --- a/test/util/model-tests.js +++ b/test/util/model-tests.js @@ -51,7 +51,8 @@ module.exports = function defineModelTestsWithDataSource(options) { 'domain': String, 'email': String }, { - trackChanges: true + trackChanges: options.trackChanges !== false, + enableRemoteReplication: options.enableRemoteReplication, }); User.attachTo(dataSource);