不要怂,就是干,撸起袖子干!

Commit 1e94b7aa by Chase Geigle

Add tests for the previous bugfix.

1 parent 23d58fe6
...@@ -47,6 +47,17 @@ describe('BelongsTo', function() { ...@@ -47,6 +47,17 @@ describe('BelongsTo', function() {
expect(task.getPerson).toBeDefined() expect(task.getPerson).toBeDefined()
}) })
it("aliases associations to the same table according to the passed 'as' option", function() {
Task.belongsTo(User, {as: 'Poster'})
Task.belongsTo(User, {as: 'Owner'})
var task = Task.build({title: 'asd'})
expect(task.getPoster).toBeDefined()
expect(task.setPoster).toBeDefined()
expect(task.getOwner).toBeDefined()
expect(task.setOwner).toBeDefined()
})
it("intializes the foreign key with null", function() { it("intializes the foreign key with null", function() {
Task.belongsTo(User) Task.belongsTo(User)
......
...@@ -54,6 +54,17 @@ describe('HasOne', function() { ...@@ -54,6 +54,17 @@ describe('HasOne', function() {
expect(u.getWork).toBeDefined() expect(u.getWork).toBeDefined()
}) })
it("aliases associations to the same table according to the passed 'as' option", function() {
User.hasOne(Task, {as: 'Work'});
User.hasOne(Task, {as: 'Play'});
var u = User.build({username: 'asd'})
expect(u.getWork).toBeDefined()
expect(u.setWork).toBeDefined()
expect(u.getPlay).toBeDefined()
expect(u.setPlay).toBeDefined()
})
it("gets and sets the correct objects", function() { it("gets and sets the correct objects", function() {
var user, task; var user, task;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!