From 55289d04c8620a955b8ac653806b3cf9459dd6a5 Mon Sep 17 00:00:00 2001 From: Nazar Gargol Date: Fri, 22 Feb 2019 12:03:19 +0700 Subject: [PATCH] Changed response structure for /images refs #10438 - To make response structure future proof and conform to the rest of API responses /images* now returns an object with url property instead of plain url string --- .../api/v2/utils/serializers/output/upload.js | 6 ++++-- core/test/acceptance/old/admin/upload_spec.js | 16 ++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/core/server/api/v2/utils/serializers/output/upload.js b/core/server/api/v2/utils/serializers/output/upload.js index 6b07d440a6..54bfd702a9 100644 --- a/core/server/api/v2/utils/serializers/output/upload.js +++ b/core/server/api/v2/utils/serializers/output/upload.js @@ -2,9 +2,11 @@ const debug = require('ghost-ignition').debug('api:v2:utils:serializers:output:u const mapper = require('./utils/mapper'); module.exports = { - image(models, apiConfig, frame) { + image(path, apiConfig, frame) { debug('image'); - return frame.response = mapper.mapImage(models); + return frame.response = { + url: mapper.mapImage(path) + }; } }; diff --git a/core/test/acceptance/old/admin/upload_spec.js b/core/test/acceptance/old/admin/upload_spec.js index 30e32c9413..f895a654bb 100644 --- a/core/test/acceptance/old/admin/upload_spec.js +++ b/core/test/acceptance/old/admin/upload_spec.js @@ -39,9 +39,9 @@ describe('Upload API', function () { return done(err); } - res.body.should.match(new RegExp(`${config.get('url')}/content/images/\\d+/\\d+/ghost-logo.png`)); + res.body.url.should.match(new RegExp(`${config.get('url')}/content/images/\\d+/\\d+/ghost-logo.png`)); - images.push(res.body.replace(config.get('url'), '')); + images.push(res.body.url.replace(config.get('url'), '')); done(); }); }); @@ -57,9 +57,9 @@ describe('Upload API', function () { return done(err); } - res.body.should.match(new RegExp(`${config.get('url')}/content/images/\\d+/\\d+/ghosticon.jpg`)); + res.body.url.should.match(new RegExp(`${config.get('url')}/content/images/\\d+/\\d+/ghosticon.jpg`)); - images.push(res.body.replace(config.get('url'), '')); + images.push(res.body.url.replace(config.get('url'), '')); done(); }); }); @@ -75,9 +75,9 @@ describe('Upload API', function () { return done(err); } - res.body.should.match(new RegExp(`${config.get('url')}/content/images/\\d+/\\d+/loadingcat.gif`)); + res.body.url.should.match(new RegExp(`${config.get('url')}/content/images/\\d+/\\d+/loadingcat.gif`)); - images.push(res.body.replace(config.get('url'), '')); + images.push(res.body.url.replace(config.get('url'), '')); done(); }); }); @@ -93,9 +93,9 @@ describe('Upload API', function () { return done(err); } - res.body.should.match(new RegExp(`${config.get('url')}/content/images/\\d+/\\d+/loadingcat_square.gif`)); + res.body.url.should.match(new RegExp(`${config.get('url')}/content/images/\\d+/\\d+/loadingcat_square.gif`)); - images.push(res.body.replace(config.get('url'), '')); + images.push(res.body.url.replace(config.get('url'), '')); done(); }); });