Skip to content

Commit

Permalink
Changed response structure for /images
Browse files Browse the repository at this point in the history
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
  • Loading branch information
naz committed Feb 22, 2019
1 parent 1876361 commit 55289d0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
6 changes: 4 additions & 2 deletions core/server/api/v2/utils/serializers/output/upload.js
Expand Up @@ -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)
};
}
};
16 changes: 8 additions & 8 deletions core/test/acceptance/old/admin/upload_spec.js
Expand Up @@ -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();
});
});
Expand All @@ -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();
});
});
Expand All @@ -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();
});
});
Expand All @@ -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();
});
});
Expand Down

0 comments on commit 55289d0

Please sign in to comment.