Skip to content

Commit

Permalink
Added test case to demonstrate issue sequelize#2316
Browse files Browse the repository at this point in the history
  • Loading branch information
haches authored and Joel Trost committed Oct 27, 2014
1 parent fa9a674 commit 873684b
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions test/associations/has-many.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2108,22 +2108,17 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
});

describe('project has owners and users and owners and users have projects', function() {
beforeEach(function() {
beforeEach(function() {
this.Project.hasMany(this.User, { as: 'owners', through: 'projectOwners'});
this.Project.hasMany(this.User, { as: 'users', through: 'projectUsers'});

this.User.hasMany(this.Project, { as: 'ownedProjects', through: 'projectOwners'});
this.User.hasMany(this.Project, { as: 'memberProjects', through: 'projectUsers'});
this.User.hasMany(this.Project, { as: 'owners', through: 'projectOwners'});
this.User.hasMany(this.User, { as: 'users', through: 'projectUsers'});


return this.sequelize.sync({ force: true });
});

it('correctly pairs associations', function () {
expect(this.Project.associations.owners.targetAssociation).to.equal(this.User.associations.ownedProjects);
expect(this.Project.associations.users.targetAssociation).to.equal(this.User.associations.memberProjects);
});


it('correctly sets user and owner', function() {
var self = this;

Expand Down

0 comments on commit 873684b

Please sign in to comment.