Skip to content

Commit

Permalink
Merge f74f667 into eed1ec5
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoboucas committed Jul 17, 2018
2 parents eed1ec5 + f74f667 commit e3f6cae
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dadi/lib/controller/collections.js
Expand Up @@ -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
}

Expand Down
34 changes: 34 additions & 0 deletions test/acceptance/collections-endpoint.js
Expand Up @@ -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()
})
})
})
})

0 comments on commit e3f6cae

Please sign in to comment.