Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ app.model = function(Model, config) {
this.models().push(Model);

if (isPublic && Model.sharedClass) {
this.remotes().defineObjectType(Model.modelName, function(data) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah this is what I was missing

return new Model(data);
});
this.remotes().addClass(Model.sharedClass);
if (Model.settings.trackChanges && Model.Change) {
this.remotes().addClass(Model.Change.sharedClass);
Expand Down Expand Up @@ -316,8 +319,10 @@ app.enableAuth = function(options) {
g.f('Authentication requires model %s to be defined.', m));
}

if (m.dataSource || m.app) return;
if (Model.dataSource || Model.app) return;

// Find descendants of Model that are attached,
// for example "Customer" extending "User" model
for (var name in appModels) {
var candidate = appModels[name];
var isSubclass = candidate.prototype instanceof Model;
Expand Down
5 changes: 0 additions & 5 deletions lib/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,6 @@ module.exports = function(registry) {
remotingOptions
);

// setup a remoting type converter for this model
RemoteObjects.convert(typeName, function(val) {
return val ? new ModelCtor(val) : val;
});

// support remoting prototype methods
ModelCtor.sharedCtor = function(data, id, fn) {
var ModelCtor = this;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"ejs": "^2.3.1",
"express": "^4.14.0",
"inflection": "^1.6.0",
"loopback-connector-remote": "^2.0.0-alpha.1",
"loopback-connector-remote": "^2.0.0-alpha.2",
"loopback-datasource-juggler": "^3.0.0-alpha.7",
"isemail": "^1.2.0",
"loopback-phase": "^1.2.0",
Expand All @@ -55,7 +55,7 @@
"serve-favicon": "^2.2.0",
"stable": "^0.1.5",
"strong-globalize": "^2.6.2",
"strong-remoting": "^3.0.0-alpha.5",
"strong-remoting": "^3.0.0-alpha.6",
"uid2": "0.0.3",
"underscore.string": "^3.0.3"
},
Expand Down
3 changes: 3 additions & 0 deletions test/relations.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,9 @@ describe('relations - integration', function() {

describe('hasAndBelongsToMany', function() {
beforeEach(function defineProductAndCategoryModels() {
// Disable "Warning: overriding remoting type product"
this.app.remotes()._typeRegistry._options.warnWhenOverridingType = false;

var product = app.registry.createModel(
'product',
{ id: 'string', name: 'string' }
Expand Down
8 changes: 7 additions & 1 deletion test/remote-connector.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ describe('RemoteConnector', function() {
beforeEach: function(done) {
var test = this;
remoteApp = loopback();
remoteApp.set('remoting', { errorHandler: { debug: true, log: false }});
remoteApp.set('remoting', {
errorHandler: { debug: true, log: false },
types: { warnWhenOverridingType: false },
});
remoteApp.use(loopback.rest());
remoteApp.listen(0, function() {
test.dataSource = loopback.createDataSource({
Expand Down Expand Up @@ -51,6 +54,9 @@ describe('RemoteConnector', function() {
beforeEach(function(done) {
var test = this;
remoteApp = this.remoteApp = loopback();
remoteApp.set('remoting', {
types: { warnWhenOverridingType: false },
});
remoteApp.use(loopback.rest());
var ServerModel = this.ServerModel = loopback.PersistedModel.extend('TestModel');

Expand Down
1 change: 0 additions & 1 deletion test/user.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ describe('User', function() {
app.enableAuth({ dataSource: 'db' });
app.use(loopback.token({ model: AccessToken }));
app.use(loopback.rest());
app.model(User);

User.create(validCredentials, function(err, user) {
if (err) return done(err);
Expand Down