From c3d19a49070aedb0e9accedf46465196b677406e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 12 Jun 2017 21:31:58 +0200 Subject: [PATCH] Fix video update test --- server/controllers/api/videos/index.ts | 2 +- server/tests/utils/videos.js | 33 ++++++++++++-------------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index 3b2ac4a6c..5e8cf2d25 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts @@ -356,7 +356,7 @@ function updateVideo (req: express.Request, res: express.Response, finalCallback return rollbackTransaction(err, t, finalCallback) } - logger.info('Video with name %s updated.', videoInfosToUpdate.name) + logger.info('Video with name %s updated.', videoInstance.name) return finalCallback(null) }) } diff --git a/server/tests/utils/videos.js b/server/tests/utils/videos.js index f0eeec497..6e7aabc5d 100644 --- a/server/tests/utils/videos.js +++ b/server/tests/utils/videos.js @@ -272,26 +272,23 @@ function updateVideo (url, accessToken, id, attributes, specialStatus, end) { } const path = '/api/v1/videos/' + id + const body = {} - const req = request(url) - .put(path) - .set('Accept', 'application/json') - .set('Authorization', 'Bearer ' + accessToken) + if (attributes.name) body.name = attributes.name + if (attributes.category) body.category = attributes.category + if (attributes.licence) body.licence = attributes.licence + if (attributes.language) body.language = attributes.language + if (attributes.nsfw) body.nsfw = attributes.nsfw + if (attributes.description) body.description = attributes.description + if (attributes.tags) body.tags = attributes.tags - if (attributes.name) req.field('name', attributes.name) - if (attributes.category) req.field('category', attributes.category) - if (attributes.licence) req.field('licence', attributes.licence) - if (attributes.language) req.field('language', attributes.language) - if (attributes.nsfw) req.field('nsfw', attributes.nsfw) - if (attributes.description) req.field('description', attributes.description) - - if (attributes.tags) { - for (let i = 0; i < attributes.tags.length; i++) { - req.field('tags[' + i + ']', attributes.tags[i]) - } - } - - req.expect(specialStatus).end(end) + request(url) + .put(path) + .send(body) + .set('Accept', 'application/json') + .set('Authorization', 'Bearer ' + accessToken) + .expect(specialStatus) + .end(end) } function rateVideo (url, accessToken, id, rating, specialStatus, end) { -- 2.25.1