Skip to content

Commit beffce3

Browse files
committed
fixing test
1 parent 75bbd44 commit beffce3

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

middleware/apply-scope.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ module.exports = {
4343
if (sift) req.appliedScope = sift;
4444
} else {
4545
for (const scope of req.controller.scopes) {
46-
if (req.user.scope.indexOf(scope) > -1) req.appliedScope = scope;
46+
if (req.user.scope && req.user.scope.indexOf(scope) > -1) req.appliedScope = scope;
4747
}
4848

4949
}

test/test.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,9 @@ describe('[MIDDLEWARE]', function() {
628628
var request = httpMocks.createRequest({
629629
caughtScope: [ '*', 'admin' ],
630630
method: 'GET',
631-
user: {},
631+
user: {
632+
scope: [ 'admin' ]
633+
},
632634
controller: {
633635
scopes: [ '*', 'owner', 'admin' ],
634636
_rest: false,
@@ -641,6 +643,7 @@ describe('[MIDDLEWARE]', function() {
641643
var response = httpMocks.createResponse();
642644

643645
middleware(request, response, function() {
646+
console.log(request.appliedScope);
644647
expect(request).to.have.property('appliedScope');
645648
expect(request.appliedScope).to.equal('admin');
646649
});

0 commit comments

Comments
 (0)