Merge pull request #3540 from lehni/fix/isStatic-method-settings

Do not add isStatic properties to method settings
This commit is contained in:
Miroslav Bajtoš 2017-08-16 15:55:11 +02:00 committed by GitHub
commit 2ebe38b4d5
2 changed files with 15 additions and 1 deletions

View File

@ -273,7 +273,7 @@ Registry.prototype._defineRemoteMethods = function(ModelCtor, methods) {
if (typeof meta.isStatic !== 'boolean') { if (typeof meta.isStatic !== 'boolean') {
key = isStatic ? key : m[1]; key = isStatic ? key : m[1];
meta.isStatic = isStatic; meta = Object.assign({}, meta, {isStatic});
} else if (meta.isStatic && m) { } else if (meta.isStatic && m) {
throw new Error(g.f('Remoting metadata for %s.%s {{"isStatic"}} does ' + throw new Error(g.f('Remoting metadata for %s.%s {{"isStatic"}} does ' +
'not match new method name-based style.', ModelCtor.modelName, key)); 'not match new method name-based style.', ModelCtor.modelName, key));

View File

@ -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({});
});
});
}); });