Removed unnecessary tags serializer

refs: https://github.com/TryGhost/Toolbox/issues/245

- we don't need this serializer because the default serializer will call the tags mapper
- for now I've changed, rather than removed the tag serializer test as this shows default works the same!
This commit is contained in:
Hannah Wolfe 2022-03-21 20:49:01 +00:00
parent b28beed755
commit 9db1694647
3 changed files with 4 additions and 33 deletions

View File

@ -93,10 +93,6 @@ module.exports = {
return require('./files');
},
get tags() {
return require('./tags');
},
get users() {
return require('./users');
},

View File

@ -1,25 +0,0 @@
const debug = require('@tryghost/debug')('api:canary:utils:serializers:output:tags');
const mappers = require('./mappers');
module.exports = {
all(models, apiConfig, frame) {
debug('all');
if (!models) {
return;
}
if (models.meta) {
frame.response = {
tags: models.data.map(model => mappers.tags(model, frame)),
meta: models.meta
};
return;
}
frame.response = {
tags: [mappers.tags(models, frame)]
};
}
};

View File

@ -20,7 +20,7 @@ describe('Unit: canary/utils/serializers/output/tags', function () {
});
it('calls the mapper when single tag present', function () {
const apiConfig = {};
const apiConfig = {docName: 'tags'};
const frame = {
options: {
context: {}
@ -29,14 +29,14 @@ describe('Unit: canary/utils/serializers/output/tags', function () {
const ctrlResponse = tagModel(testUtils.DataGenerator.forKnex.createTag());
serializers.output.tags.all(ctrlResponse, apiConfig, frame);
serializers.output.default.all(ctrlResponse, apiConfig, frame);
mappers.tags.callCount.should.equal(1);
mappers.tags.getCall(0).args.should.eql([ctrlResponse, frame]);
});
it('calls the mapper with multiple tags', function () {
const apiConfig = {};
const apiConfig = {docName: 'tags'};
const frame = {
options: {
context: {}
@ -51,7 +51,7 @@ describe('Unit: canary/utils/serializers/output/tags', function () {
meta: {}
});
serializers.output.tags.all(ctrlResponse, apiConfig, frame);
serializers.output.default.all(ctrlResponse, apiConfig, frame);
mappers.tags.callCount.should.equal(2);
mappers.tags.getCall(0).args.should.eql([ctrlResponse.data[0], frame]);