mirror of
https://github.com/strapi/strapi.git
synced 2025-11-01 02:16:03 +00:00
default populate files
This commit is contained in:
parent
34046abe1f
commit
eb2ec33426
@ -1,5 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const { merge } = require('lodash/fp');
|
||||
const { getService } = require('../utils');
|
||||
const { ACTIONS, FILE_MODEL_UID } = require('../constants');
|
||||
const { findEntityAndCheckPermissions } = require('./utils/find-entity-and-check-permissions');
|
||||
@ -10,6 +11,8 @@ module.exports = {
|
||||
state: { userAbility },
|
||||
} = ctx;
|
||||
|
||||
const defaultQuery = { populate: { folder: true } };
|
||||
|
||||
const pm = strapi.admin.services.permission.createPermissionsManager({
|
||||
ability: userAbility,
|
||||
action: ACTIONS.read,
|
||||
@ -20,7 +23,7 @@ module.exports = {
|
||||
return ctx.forbidden();
|
||||
}
|
||||
|
||||
const query = pm.addPermissionsQueryTo(ctx.query);
|
||||
const query = pm.addPermissionsQueryTo(merge(defaultQuery, ctx.query));
|
||||
|
||||
const { results, pagination } = await getService('upload').findPage(query);
|
||||
|
||||
|
||||
@ -54,10 +54,10 @@ describe('Upload', () => {
|
||||
|
||||
describe('Read', () => {
|
||||
test('GET /upload/files => Find files', async () => {
|
||||
const getRes = await rq({ method: 'GET', url: '/upload/files' });
|
||||
const res = await rq({ method: 'GET', url: '/upload/files' });
|
||||
|
||||
expect(getRes.statusCode).toBe(200);
|
||||
expect(getRes.body).toEqual({
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toEqual({
|
||||
results: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: expect.anything(),
|
||||
@ -71,6 +71,7 @@ describe('Upload', () => {
|
||||
total: expect.any(Number),
|
||||
},
|
||||
});
|
||||
res.body.results.forEach(file => expect(file.folder).toBeDefined());
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user