Add a test case for relations during attach

This commit is contained in:
Raymond Feng 2013-11-07 13:28:18 -08:00
parent 566da386ae
commit 89a30e7edd
1 changed files with 14 additions and 0 deletions

View File

@ -530,6 +530,20 @@ describe('Load models with relations', function () {
done();
});
it('should set up relations after attach', function (done) {
var ds = new DataSource('memory');
var modelBuilder = new ModelBuilder();
var Post = modelBuilder.define('Post', {userId: Number, content: String});
var User = modelBuilder.define('User', {name: String}, {relations: {posts: {type: 'hasMany', model: 'Post'}}});
assert(!User.relations['posts']);
Post.attachTo(ds);
User.attachTo(ds);
assert(User.relations['posts']);
done();
});
});