fix tests

Signed-off-by: Pierre Noël <petersg83@gmail.com>
This commit is contained in:
Pierre Noël 2020-09-08 15:18:32 +02:00
parent 74a85c1127
commit 09ae61ffab
2 changed files with 7 additions and 7 deletions

View File

@ -158,7 +158,7 @@ module.exports = {
}
const data = await validateUploadBody(body);
const file = await uploadService.replace(id, { data, file: files, user });
const file = await uploadService.replace(id, { data, file: files }, { user });
ctx.body = pm.sanitize(file, { action: ACTIONS.read });
},
@ -181,7 +181,7 @@ module.exports = {
}
const data = await validateUploadBody(body);
const file = await uploadService.upload({ data, files, user });
const file = await uploadService.upload({ data, files }, { user });
ctx.body = pm.sanitize(file, { action: ACTIONS.read });
},

View File

@ -108,7 +108,7 @@ module.exports = {
});
},
async upload({ data, files, user }) {
async upload({ data, files }, { user } = {}) {
const { fileInfo, ...metas } = data;
const fileArray = Array.isArray(files) ? files : [files];
@ -170,7 +170,7 @@ module.exports = {
return this.add(fileData, { user });
},
async updateFileInfo(id, { name, alternativeText, caption }, { user }) {
async updateFileInfo(id, { name, alternativeText, caption }, { user } = {}) {
const dbFile = await this.fetch({ id });
if (!dbFile) {
@ -186,7 +186,7 @@ module.exports = {
return this.update({ id }, newInfos, { user });
},
async replace(id, { data, file, user }) {
async replace(id, { data, file }, { user } = {}) {
const config = strapi.plugins.upload.config;
const {
@ -261,7 +261,7 @@ module.exports = {
return this.update({ id }, fileData, { user });
},
async update(params, values, { user }) {
async update(params, values, { user } = {}) {
const fileValues = { ...values };
if (user) {
fileValues[UPDATED_BY_ATTRIBUTE] = user.id;
@ -274,7 +274,7 @@ module.exports = {
return res;
},
async add(values, { user }) {
async add(values, { user } = {}) {
const fileValues = { ...values };
if (user) {
fileValues[UPDATED_BY_ATTRIBUTE] = user.id;