mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
Added serializer for integrations.destroy
refs: https://github.com/TryGhost/Toolbox/issues/245 - The destroy endpoint was missing a serializer - Instead of adding one, we've refactored to use the standard structure for this serializer - Updated the tests to prove the body doesn't change
This commit is contained in:
parent
7433378e6a
commit
c89a01b031
2 changed files with 20 additions and 26 deletions
|
@ -2,33 +2,24 @@ const debug = require('@tryghost/debug')('api:canary:utils:serializers:output:in
|
||||||
const mappers = require('./mappers');
|
const mappers = require('./mappers');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
browse({data, meta}, apiConfig, frame) {
|
all(models, apiConfig, frame) {
|
||||||
debug('browse');
|
debug('all');
|
||||||
|
|
||||||
|
if (!models) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (models.meta) {
|
||||||
|
frame.response = {
|
||||||
|
integrations: models.data.map(model => mappers.integrations(model, frame)),
|
||||||
|
meta: models.meta
|
||||||
|
};
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
frame.response = {
|
frame.response = {
|
||||||
integrations: data.map(model => mappers.integrations(model, frame)),
|
integrations: [mappers.integrations(models, frame)]
|
||||||
meta
|
|
||||||
};
|
|
||||||
},
|
|
||||||
read(model, apiConfig, frame) {
|
|
||||||
debug('read');
|
|
||||||
|
|
||||||
frame.response = {
|
|
||||||
integrations: [mappers.integrations(model, frame)]
|
|
||||||
};
|
|
||||||
},
|
|
||||||
add(model, apiConfig, frame) {
|
|
||||||
debug('add');
|
|
||||||
|
|
||||||
frame.response = {
|
|
||||||
integrations: [mappers.integrations(model, frame)]
|
|
||||||
};
|
|
||||||
},
|
|
||||||
edit(model, apiConfig, frame) {
|
|
||||||
debug('edit');
|
|
||||||
|
|
||||||
frame.response = {
|
|
||||||
integrations: [mappers.integrations(model, frame)]
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -326,7 +326,10 @@ describe('Integrations API', function () {
|
||||||
|
|
||||||
await request.del(localUtils.API.getApiQuery(`integrations/${createdIntegration.id}/`))
|
await request.del(localUtils.API.getApiQuery(`integrations/${createdIntegration.id}/`))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.expect(204);
|
.expect(204)
|
||||||
|
.expect((_res) => {
|
||||||
|
_res.body.should.be.empty();
|
||||||
|
});
|
||||||
|
|
||||||
await request.get(localUtils.API.getApiQuery(`integrations/${createdIntegration.id}/`))
|
await request.get(localUtils.API.getApiQuery(`integrations/${createdIntegration.id}/`))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
|
|
Loading…
Add table
Reference in a new issue