Merge branch 'release/2.0.0-beta5' into production

This commit is contained in:
Raymond Feng 2014-07-21 11:35:24 -07:00
commit 74aa84e019
3 changed files with 23 additions and 3 deletions

View File

@ -186,6 +186,7 @@ ModelBuilder.prototype.define = function defineClass(className, properties, sett
hiddenProperty(ModelClass, 'pluralModelName', pluralName); hiddenProperty(ModelClass, 'pluralModelName', pluralName);
hiddenProperty(ModelClass, 'relations', {}); hiddenProperty(ModelClass, 'relations', {});
hiddenProperty(ModelClass, 'http', { path: '/' + pluralName }); hiddenProperty(ModelClass, 'http', { path: '/' + pluralName });
hiddenProperty(ModelClass, 'base', ModelBaseClass);
// inherit ModelBaseClass static methods // inherit ModelBaseClass static methods
for (var i in ModelBaseClass) { for (var i in ModelBaseClass) {

View File

@ -1,6 +1,6 @@
{ {
"name": "loopback-datasource-juggler", "name": "loopback-datasource-juggler",
"version": "2.0.0-beta4", "version": "2.0.0-beta5",
"description": "LoopBack DataSoure Juggler", "description": "LoopBack DataSoure Juggler",
"keywords": [ "keywords": [
"StrongLoop", "StrongLoop",

View File

@ -552,7 +552,7 @@ describe('DataSource define model', function () {
}); });
describe('Load models with base', function () { describe('Load models with base', function () {
it('should set up base class', function (done) { it('should set up base class via base option', function () {
var ds = new ModelBuilder(); var ds = new ModelBuilder();
var User = ds.define('User', {name: String}); var User = ds.define('User', {name: String});
@ -567,14 +567,33 @@ describe('Load models with base', function () {
assert(Customer.prototype instanceof User); assert(Customer.prototype instanceof User);
assert(Customer.staticMethod === User.staticMethod); assert(Customer.staticMethod === User.staticMethod);
assert(Customer.prototype.instanceMethod === User.prototype.instanceMethod); assert(Customer.prototype.instanceMethod === User.prototype.instanceMethod);
assert.equal(Customer.base, User);
assert.equal(Customer.base, Customer.super_);
try { try {
var Customer1 = ds.define('Customer1', {vip: Boolean}, {base: 'User1'}); var Customer1 = ds.define('Customer1', {vip: Boolean}, {base: 'User1'});
} catch (e) { } catch (e) {
assert(e); assert(e);
} }
});
done(); it('should set up base class via parent arg', function () {
var ds = new ModelBuilder();
var User = ds.define('User', {name: String});
User.staticMethod = function staticMethod() {
};
User.prototype.instanceMethod = function instanceMethod() {
};
var Customer = ds.define('Customer', {vip: Boolean}, {}, User);
assert(Customer.prototype instanceof User);
assert(Customer.staticMethod === User.staticMethod);
assert(Customer.prototype.instanceMethod === User.prototype.instanceMethod);
assert.equal(Customer.base, User);
assert.equal(Customer.base, Customer.super_);
}); });
}); });