diff --git a/dadi/lib/controller/collections.js b/dadi/lib/controller/collections.js index 96269ab5..4dbff621 100644 --- a/dadi/lib/controller/collections.js +++ b/dadi/lib/controller/collections.js @@ -45,7 +45,7 @@ Collections.prototype.get = function (req, res, next) { version: parts[1], database: parts[2], name: (model.settings && model.settings.displayName) || model.name, - slug: model.slug, + slug: model.name, path: key } diff --git a/test/acceptance/collections-endpoint.js b/test/acceptance/collections-endpoint.js index 329c3108..25d1188e 100644 --- a/test/acceptance/collections-endpoint.js +++ b/test/acceptance/collections-endpoint.js @@ -117,4 +117,38 @@ describe('Collections endpoint', function () { }) }) }) + + it('should return all the collections if the requesting client has admin access', done => { + help.getBearerTokenWithPermissions({ + accessType: 'admin' + }).then(token => { + client + .get(`/api/collections`) + .set('content-type', 'application/json') + .set('Authorization', `Bearer ${token}`) + .end((err, res) => { + let allCollections = help.getCollectionMap() + + res.body.collections.length.should.eql( + Object.keys(allCollections).length + ) + + Object.keys(allCollections).forEach(key => { + let match = res.body.collections.some(collection => { + collection.version.should.be.String + collection.database.should.be.String + collection.name.should.be.String + collection.slug.should.be.String + collection.path.should.be.String + + return collection.path === key + }) + + match.should.eql(true) + }) + + done() + }) + }) + }) }) \ No newline at end of file