Skip to content

Commit

Permalink
Add two tests that pass on master but fail here
Browse files Browse the repository at this point in the history
  • Loading branch information
bajtos authored and ebarault committed Feb 16, 2017
1 parent 0dbfe89 commit 6453e8e
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions test/role.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,50 @@ describe('role model', function() {
});
});

it('resolves OWNER via "userId" property with no relation', function() {
var Album = app.registry.createModel('Album', {
name: String,
userId: Number,
});
app.model(Album, {dataSource: 'db'});

var user;
return User.create({email: 'test@example.com', password: 'pass'})
.then(u => {
user = u;
return Album.create({name: 'Album 1', userId: user.id});
})
.then(album => {
return Role.isInRole(Role.OWNER, {
principalType: ACL.USER, principalId: user.id,
model: Album, id: album.id,
});
})
.then(isInRole => expect(isInRole).to.be.true());
});

it('resolves OWNER via "owner" property with no relation', function() {
var Album = app.registry.createModel('Album', {
name: String,
owner: Number,
});
app.model(Album, {dataSource: 'db'});

var user;
return User.create({email: 'test@example.com', password: 'pass'})
.then(u => {
user = u;
return Album.create({name: 'Album 1', owner: user.id});
})
.then(album => {
return Role.isInRole(Role.OWNER, {
principalType: ACL.USER, principalId: user.id,
model: Album, id: album.id,
});
})
.then(isInRole => expect(isInRole).to.be.true());
});

describe('isMappedToRole', function() {
var user, app, role;

Expand Down

0 comments on commit 6453e8e

Please sign in to comment.