From a736f782af2b525e0c439de37c9ce75795f33881 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Tue, 15 Aug 2017 18:09:16 +0200 Subject: [PATCH] Do not add isStatic properties to method settings Closes #3529 --- lib/registry.js | 2 +- test/model.test.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/registry.js b/lib/registry.js index 363c6686..ea0195a4 100644 --- a/lib/registry.js +++ b/lib/registry.js @@ -273,7 +273,7 @@ Registry.prototype._defineRemoteMethods = function(ModelCtor, methods) { if (typeof meta.isStatic !== 'boolean') { key = isStatic ? key : m[1]; - meta.isStatic = isStatic; + meta = Object.assign({}, meta, {isStatic}); } else if (meta.isStatic && m) { throw new Error(g.f('Remoting metadata for %s.%s {{"isStatic"}} does ' + 'not match new method name-based style.', ModelCtor.modelName, key)); diff --git a/test/model.test.js b/test/model.test.js index f36557b5..4693f66c 100644 --- a/test/model.test.js +++ b/test/model.test.js @@ -1032,4 +1032,18 @@ describe.onServer('Remote Methods', function() { }); } }); + + describe('Create Model with remote methods from JSON description', function() { + it('does not add isStatic properties to the method settings', function() { + const app = loopback(); + const Foo = app.registry.createModel({ + name: 'Foo', + methods: { + staticMethod: {}, + }, + }); + app.model(Foo); + expect(app.models.Foo.settings.methods.staticMethod).to.eql({}); + }); + }); });