Merge branch 'release/2.12.0' into production
This commit is contained in:
commit
c3cc0a5d77
37
CHANGES.md
37
CHANGES.md
|
@ -1,3 +1,13 @@
|
||||||
|
2015-02-03, Version 2.12.0
|
||||||
|
==========================
|
||||||
|
|
||||||
|
* Fix the test case (Raymond Feng)
|
||||||
|
|
||||||
|
* Enable remoting for hasOne relations (Raymond Feng)
|
||||||
|
|
||||||
|
* README: add Gitter badge (Miroslav Bajtoš)
|
||||||
|
|
||||||
|
|
||||||
2015-01-27, Version 2.11.0
|
2015-01-27, Version 2.11.0
|
||||||
==========================
|
==========================
|
||||||
|
|
||||||
|
@ -43,12 +53,6 @@
|
||||||
|
|
||||||
* Allow accessType per remote method (Raymond Feng)
|
* Allow accessType per remote method (Raymond Feng)
|
||||||
|
|
||||||
* Update juggler dep (Raymond Feng)
|
|
||||||
|
|
||||||
* Fix Geo test cases (Raymond Feng)
|
|
||||||
|
|
||||||
* Allow User.hashPassword/validatePassword to be overridden (Raymond Feng)
|
|
||||||
|
|
||||||
* Use User.remoteMethod instead of loopbacks method This is needed for loopback-connector-remote authorization. Addresses https://github.com/strongloop/loopback/issues/622. (Berkeley Martinez)
|
* Use User.remoteMethod instead of loopbacks method This is needed for loopback-connector-remote authorization. Addresses https://github.com/strongloop/loopback/issues/622. (Berkeley Martinez)
|
||||||
|
|
||||||
* API and REST tests added to ensure complete and valid credentials are supplied for verified error message to be returned - tests added as suggested and fail under previous version of User model - strongloop/loopback#931 (Ron Edgecomb)
|
* API and REST tests added to ensure complete and valid credentials are supplied for verified error message to be returned - tests added as suggested and fail under previous version of User model - strongloop/loopback#931 (Ron Edgecomb)
|
||||||
|
@ -56,11 +60,6 @@
|
||||||
* Require valid login credentials before verified email check. - strongloop/loopback#931. (Ron Edgecomb)
|
* Require valid login credentials before verified email check. - strongloop/loopback#931. (Ron Edgecomb)
|
||||||
|
|
||||||
|
|
||||||
2015-01-07, Version 2.8.8
|
|
||||||
=========================
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
2015-01-07, Version 2.9.0
|
2015-01-07, Version 2.9.0
|
||||||
=========================
|
=========================
|
||||||
|
|
||||||
|
@ -77,12 +76,20 @@
|
||||||
|
|
||||||
* Update juggler dep (Raymond Feng)
|
* Update juggler dep (Raymond Feng)
|
||||||
|
|
||||||
* Fix context middleware to preserve domains (Pham Anh Tuan)
|
|
||||||
|
|
||||||
* Fix Geo test cases (Raymond Feng)
|
* Fix Geo test cases (Raymond Feng)
|
||||||
|
|
||||||
* Allow User.hashPassword/validatePassword to be overridden (Raymond Feng)
|
* Allow User.hashPassword/validatePassword to be overridden (Raymond Feng)
|
||||||
|
|
||||||
|
* API and REST tests added to ensure complete and valid credentials are supplied for verified error message to be returned - tests added as suggested and fail under previous version of User model - strongloop/loopback#931 (Ron Edgecomb)
|
||||||
|
|
||||||
|
* Require valid login credentials before verified email check. - strongloop/loopback#931. (Ron Edgecomb)
|
||||||
|
|
||||||
|
|
||||||
|
2015-01-07, Version 2.8.8
|
||||||
|
=========================
|
||||||
|
|
||||||
|
* Fix context middleware to preserve domains (Pham Anh Tuan)
|
||||||
|
|
||||||
* Additional password reset unit tests for API and REST - strongloop/loopback#944 (Ron Edgecomb)
|
* Additional password reset unit tests for API and REST - strongloop/loopback#944 (Ron Edgecomb)
|
||||||
|
|
||||||
* Small formatting update to have consistency with identical logic in other areas. - strongloop/loopback#944 (Ron Edgecomb)
|
* Small formatting update to have consistency with identical logic in other areas. - strongloop/loopback#944 (Ron Edgecomb)
|
||||||
|
@ -97,10 +104,6 @@
|
||||||
|
|
||||||
* Update to demonstrate unit test is actually failing due to incorrect values of invalidCredentials - strongloop/loopback#944 (Ron Edgecomb)
|
* Update to demonstrate unit test is actually failing due to incorrect values of invalidCredentials - strongloop/loopback#944 (Ron Edgecomb)
|
||||||
|
|
||||||
* API and REST tests added to ensure complete and valid credentials are supplied for verified error message to be returned - tests added as suggested and fail under previous version of User model - strongloop/loopback#931 (Ron Edgecomb)
|
|
||||||
|
|
||||||
* Require valid login credentials before verified email check. - strongloop/loopback#931. (Ron Edgecomb)
|
|
||||||
|
|
||||||
* fix jscs warning (Clark Wang)
|
* fix jscs warning (Clark Wang)
|
||||||
|
|
||||||
* fix nestRemoting is nesting hooks from other relations (Clark Wang)
|
* fix nestRemoting is nesting hooks from other relations (Clark Wang)
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
# LoopBack
|
||||||
|
|
||||||
|
[](https://gitter.im/strongloop/loopback?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||||
|
|
||||||
LoopBack is a highly-extensible, open-source Node.js framework that enables you to:
|
LoopBack is a highly-extensible, open-source Node.js framework that enables you to:
|
||||||
|
|
||||||
* Create dynamic end-to-end REST APIs with little or no coding.
|
* Create dynamic end-to-end REST APIs with little or no coding.
|
||||||
|
|
31
lib/model.js
31
lib/model.js
|
@ -432,8 +432,9 @@ Model.belongsToRemoting = function(relationName, relation, define) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Model.hasOneRemoting = function(relationName, relation, define) {
|
Model.hasOneRemoting = function(relationName, relation, define) {
|
||||||
var fn = this.prototype[relationName];
|
|
||||||
var pathName = (relation.options.http && relation.options.http.path) || relationName;
|
var pathName = (relation.options.http && relation.options.http.path) || relationName;
|
||||||
|
var toModelName = relation.modelTo.modelName;
|
||||||
|
|
||||||
define('__get__' + relationName, {
|
define('__get__' + relationName, {
|
||||||
isStatic: false,
|
isStatic: false,
|
||||||
http: {verb: 'get', path: '/' + pathName},
|
http: {verb: 'get', path: '/' + pathName},
|
||||||
|
@ -441,7 +442,33 @@ Model.hasOneRemoting = function(relationName, relation, define) {
|
||||||
description: 'Fetches hasOne relation ' + relationName,
|
description: 'Fetches hasOne relation ' + relationName,
|
||||||
accessType: 'READ',
|
accessType: 'READ',
|
||||||
returns: {arg: relationName, type: relation.modelTo.modelName, root: true}
|
returns: {arg: relationName, type: relation.modelTo.modelName, root: true}
|
||||||
}, fn);
|
});
|
||||||
|
|
||||||
|
define('__create__' + relationName, {
|
||||||
|
isStatic: false,
|
||||||
|
http: {verb: 'post', path: '/' + pathName},
|
||||||
|
accepts: {arg: 'data', type: toModelName, http: {source: 'body'}},
|
||||||
|
description: 'Creates a new instance in ' + relationName + ' of this model.',
|
||||||
|
accessType: 'WRITE',
|
||||||
|
returns: {arg: 'data', type: toModelName, root: true}
|
||||||
|
});
|
||||||
|
|
||||||
|
define('__update__' + relationName, {
|
||||||
|
isStatic: false,
|
||||||
|
http: {verb: 'put', path: '/' + pathName},
|
||||||
|
accepts: {arg: 'data', type: toModelName, http: {source: 'body'}},
|
||||||
|
description: 'Update ' + relationName + ' of this model.',
|
||||||
|
accessType: 'WRITE',
|
||||||
|
returns: {arg: 'data', type: toModelName, root: true}
|
||||||
|
});
|
||||||
|
|
||||||
|
define('__destroy__' + relationName, {
|
||||||
|
isStatic: false,
|
||||||
|
http: {verb: 'delete', path: '/' + pathName},
|
||||||
|
description: 'Deletes ' + relationName + ' of this model.',
|
||||||
|
accessType: 'WRITE'
|
||||||
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Model.hasManyRemoting = function(relationName, relation, define) {
|
Model.hasManyRemoting = function(relationName, relation, define) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "loopback",
|
"name": "loopback",
|
||||||
"version": "2.11.0",
|
"version": "2.12.0",
|
||||||
"description": "LoopBack: Open Source Framework for Node.js",
|
"description": "LoopBack: Open Source Framework for Node.js",
|
||||||
"homepage": "http://loopback.io",
|
"homepage": "http://loopback.io",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
@ -102,6 +102,6 @@
|
||||||
"url": "https://github.com/strongloop/loopback/blob/master/LICENSE"
|
"url": "https://github.com/strongloop/loopback/blob/master/LICENSE"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"sl-blip": "http://blip.strongloop.com/loopback@2.11.0"
|
"sl-blip": "http://blip.strongloop.com/loopback@2.12.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,5 +114,32 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"customer": {
|
||||||
|
"base": "PersistedModel",
|
||||||
|
"dataSource": "db",
|
||||||
|
"public": true,
|
||||||
|
"properties": {
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"relations": {
|
||||||
|
"profile": {
|
||||||
|
"type": "hasOne",
|
||||||
|
"model": "profile"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"profile": {
|
||||||
|
"base": "PersistedModel",
|
||||||
|
"dataSource": "db",
|
||||||
|
"public": true,
|
||||||
|
"properties": {
|
||||||
|
"points": {
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1360,4 +1360,96 @@ describe('relations - integration', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('hasOne', function() {
|
||||||
|
var cust;
|
||||||
|
|
||||||
|
before(function createCustomer(done) {
|
||||||
|
var test = this;
|
||||||
|
app.models.customer.create({ name: 'John' }, function(err, c) {
|
||||||
|
if (err) {
|
||||||
|
return done(err);
|
||||||
|
}
|
||||||
|
cust = c;
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
after(function(done) {
|
||||||
|
var self = this;
|
||||||
|
this.app.models.customer.destroyAll(function(err) {
|
||||||
|
if (err) {
|
||||||
|
return done(err);
|
||||||
|
}
|
||||||
|
self.app.models.profile.destroyAll(done);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create the referenced model', function(done) {
|
||||||
|
var url = '/api/customers/' + cust.id + '/profile';
|
||||||
|
|
||||||
|
this.post(url)
|
||||||
|
.send({points: 10})
|
||||||
|
.expect(200, function(err, res) {
|
||||||
|
if (err) {
|
||||||
|
return done(err);
|
||||||
|
}
|
||||||
|
expect(res.body.points).to.be.eql(10);
|
||||||
|
expect(res.body.customerId).to.be.eql(cust.id);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should find the referenced model', function(done) {
|
||||||
|
var url = '/api/customers/' + cust.id + '/profile';
|
||||||
|
this.get(url)
|
||||||
|
.expect(200, function(err, res) {
|
||||||
|
if (err) {
|
||||||
|
return done(err);
|
||||||
|
}
|
||||||
|
expect(res.body.points).to.be.eql(10);
|
||||||
|
expect(res.body.customerId).to.be.eql(cust.id);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not create the referenced model twice', function(done) {
|
||||||
|
var url = '/api/customers/' + cust.id + '/profile';
|
||||||
|
this.post(url)
|
||||||
|
.send({points: 20})
|
||||||
|
.expect(500, function(err, res) {
|
||||||
|
done(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should update the referenced model', function(done) {
|
||||||
|
var url = '/api/customers/' + cust.id + '/profile';
|
||||||
|
this.put(url)
|
||||||
|
.send({points: 100})
|
||||||
|
.expect(200, function(err, res) {
|
||||||
|
if (err) {
|
||||||
|
return done(err);
|
||||||
|
}
|
||||||
|
expect(res.body.points).to.be.eql(100);
|
||||||
|
expect(res.body.customerId).to.be.eql(cust.id);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should delete the referenced model', function(done) {
|
||||||
|
var url = '/api/customers/' + cust.id + '/profile';
|
||||||
|
this.del(url)
|
||||||
|
.expect(204, function(err, res) {
|
||||||
|
done(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not find the referenced model', function(done) {
|
||||||
|
var url = '/api/customers/' + cust.id + '/profile';
|
||||||
|
this.get(url)
|
||||||
|
.expect(404, function(err, res) {
|
||||||
|
done(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -79,7 +79,7 @@ describe('User', function() {
|
||||||
assert.equal(err.details.context, 'user');
|
assert.equal(err.details.context, 'user');
|
||||||
assert.deepEqual(err.details.codes.email, [
|
assert.deepEqual(err.details.codes.email, [
|
||||||
'presence',
|
'presence',
|
||||||
'format.blank'
|
'format.null'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
done();
|
done();
|
||||||
|
|
Loading…
Reference in New Issue