mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Removed author
from Admin API v2 output
refs #10438 - single author is deprecated and get's completely dropped in v3
This commit is contained in:
parent
7f7b477ce9
commit
93092c8f20
5 changed files with 36 additions and 66 deletions
|
@ -1,3 +1,5 @@
|
|||
const localUtils = require('../../../index');
|
||||
|
||||
const tag = (attrs) => {
|
||||
// Already deleted in model.toJSON, but leaving here so that we can clean that up when we deprecate v0.1
|
||||
delete attrs.parent_id;
|
||||
|
@ -61,36 +63,38 @@ const author = (attrs) => {
|
|||
return attrs;
|
||||
};
|
||||
|
||||
const post = (attrs) => {
|
||||
// Extra properties removed from v2
|
||||
delete attrs.locale;
|
||||
const post = (attrs, frame) => {
|
||||
if (localUtils.isContentAPI(frame)) {
|
||||
delete attrs.locale;
|
||||
|
||||
// @TODO: https://github.com/TryGhost/Ghost/issues/10335
|
||||
// delete attrs.page;
|
||||
delete attrs.status;
|
||||
delete attrs.visibility;
|
||||
|
||||
// We are standardising on returning null from the Content API for any empty values
|
||||
if (attrs.twitter_title === '') {
|
||||
attrs.twitter_title = null;
|
||||
}
|
||||
if (attrs.twitter_description === '') {
|
||||
attrs.twitter_description = null;
|
||||
}
|
||||
if (attrs.meta_title === '') {
|
||||
attrs.meta_title = null;
|
||||
}
|
||||
if (attrs.meta_description === '') {
|
||||
attrs.meta_description = null;
|
||||
}
|
||||
if (attrs.og_title === '') {
|
||||
attrs.og_title = null;
|
||||
}
|
||||
if (attrs.og_description === '') {
|
||||
attrs.og_description = null;
|
||||
}
|
||||
}
|
||||
|
||||
delete attrs.author;
|
||||
|
||||
// @TODO: https://github.com/TryGhost/Ghost/issues/10335
|
||||
// delete attrs.page;
|
||||
delete attrs.status;
|
||||
delete attrs.visibility;
|
||||
|
||||
// We are standardising on returning null from the Content API for any empty values
|
||||
if (attrs.twitter_title === '') {
|
||||
attrs.twitter_title = null;
|
||||
}
|
||||
if (attrs.twitter_description === '') {
|
||||
attrs.twitter_description = null;
|
||||
}
|
||||
if (attrs.meta_title === '') {
|
||||
attrs.meta_title = null;
|
||||
}
|
||||
if (attrs.meta_description === '') {
|
||||
attrs.meta_description = null;
|
||||
}
|
||||
if (attrs.og_title === '') {
|
||||
attrs.og_title = null;
|
||||
}
|
||||
if (attrs.og_description === '') {
|
||||
attrs.og_description = null;
|
||||
}
|
||||
|
||||
return attrs;
|
||||
};
|
||||
|
||||
|
|
|
@ -38,9 +38,10 @@ const mapPost = (model, frame) => {
|
|||
date.forPost(jsonModel);
|
||||
members.forPost(jsonModel, frame);
|
||||
extraAttrs.forPost(frame, model, jsonModel);
|
||||
clean.post(jsonModel);
|
||||
}
|
||||
|
||||
clean.post(jsonModel, frame);
|
||||
|
||||
if (frame.options && frame.options.withRelated) {
|
||||
frame.options.withRelated.forEach((relation) => {
|
||||
// @NOTE: this block also decorates primary_tag/primary_author objects as they
|
||||
|
|
|
@ -247,7 +247,6 @@ describe('Posts API V2', function () {
|
|||
jsonResponse.posts[0].page.should.not.be.ok();
|
||||
_.isBoolean(jsonResponse.posts[0].featured).should.eql(true);
|
||||
_.isBoolean(jsonResponse.posts[0].page).should.eql(true);
|
||||
jsonResponse.posts[0].author.should.be.a.String();
|
||||
testUtils.API.isISO8601(jsonResponse.posts[0].created_at).should.be.true();
|
||||
// Tags aren't included by default
|
||||
should.not.exist(jsonResponse.posts[0].tags);
|
||||
|
@ -299,7 +298,6 @@ describe('Posts API V2', function () {
|
|||
jsonResponse.posts[0].page.should.not.be.ok();
|
||||
_.isBoolean(jsonResponse.posts[0].featured).should.eql(true);
|
||||
_.isBoolean(jsonResponse.posts[0].page).should.eql(true);
|
||||
jsonResponse.posts[0].author.should.be.a.String();
|
||||
// Tags aren't included by default
|
||||
should.not.exist(jsonResponse.posts[0].tags);
|
||||
done();
|
||||
|
@ -325,7 +323,6 @@ describe('Posts API V2', function () {
|
|||
|
||||
localUtils.API.checkResponse(jsonResponse.posts[0], 'post', ['tags', 'authors']);
|
||||
|
||||
jsonResponse.posts[0].author.should.be.a.String();
|
||||
jsonResponse.posts[0].page.should.not.be.ok();
|
||||
|
||||
jsonResponse.posts[0].authors[0].should.be.an.Object();
|
||||
|
@ -448,7 +445,6 @@ describe('Posts API V2', function () {
|
|||
localUtils.API.checkResponse(res.body.posts[0], 'post');
|
||||
|
||||
res.body.posts[0].title.should.eql(post.title);
|
||||
res.body.posts[0].author.should.eql(post.author);
|
||||
res.body.posts[0].status.should.eql('published');
|
||||
res.body.posts[0].custom_template.should.eql('custom-about');
|
||||
});
|
||||
|
|
|
@ -22,8 +22,8 @@ const expectedProperties = {
|
|||
.keys()
|
||||
// by default we only return html
|
||||
.without('mobiledoc', 'plaintext')
|
||||
// swaps author_id to author, and always returns computed properties: url, comment_id, primary_tag, primary_author
|
||||
.without('author_id').concat('author', 'url', 'primary_tag', 'primary_author')
|
||||
// always returns computed properties: url, comment_id, primary_tag, primary_author
|
||||
.without('author_id').concat('url', 'primary_tag', 'primary_author')
|
||||
,
|
||||
user: _(schema.users)
|
||||
.keys()
|
||||
|
|
|
@ -78,37 +78,6 @@ describe('Unit: v2/utils/serializers/output/utils/mapper', () => {
|
|||
urlUtil.forTag.getCall(0).args.should.eql(['id3', {id: 'id3', feature_image: 'value'}]);
|
||||
urlUtil.forUser.getCall(0).args.should.eql(['id4', {name: 'Ghosty', id: 'id4'}]);
|
||||
});
|
||||
|
||||
it('does not call cleanUtil in private context', () => {
|
||||
const frame = {
|
||||
withRelated: ['tags', 'authors'],
|
||||
options: {
|
||||
context: {
|
||||
public: false
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const post = postModel(testUtils.DataGenerator.forKnex.createPost({
|
||||
id: 'id1',
|
||||
feature_image: 'value',
|
||||
page: true,
|
||||
tags: [{
|
||||
id: 'id3',
|
||||
feature_image: 'value'
|
||||
}],
|
||||
authors: [{
|
||||
id: 'id4',
|
||||
name: 'Ghosty'
|
||||
}]
|
||||
}));
|
||||
|
||||
mapper.mapPost(post, frame);
|
||||
|
||||
cleanUtil.post.callCount.should.equal(0);
|
||||
cleanUtil.tag.callCount.should.equal(0);
|
||||
cleanUtil.author.callCount.should.equal(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('mapUser', () => {
|
||||
|
|
Loading…
Add table
Reference in a new issue