🐛 Fixed meta attributes calculation on post preview

closes https://github.com/TryGhost/Ghost/issues/12247

- Internal preview controller was lacking "mapping" call to post object which handled not only missing meta attribute information but lots of other mappings (e.g. users, tags, etc.)
- Have added a regression test to catch issues like this in the future
This commit is contained in:
Naz 2020-10-05 17:52:40 +13:00
parent b34f2e86fb
commit 39e403d176
4 changed files with 13 additions and 2 deletions

View File

@ -1,7 +1,9 @@
const mapper = require('./utils/mapper');
module.exports = {
all(model, apiConfig, frame) {
frame.response = {
preview: [model.toJSON(frame.options)]
preview: [mapper.mapPost(model, frame)]
};
}
};

View File

@ -1,7 +1,9 @@
const mapper = require('./utils/mapper');
module.exports = {
all(model, apiConfig, frame) {
frame.response = {
preview: [model.toJSON(frame.options)]
preview: [mapper.mapPost(model, frame)]
};
}
};

View File

@ -253,6 +253,8 @@ describe('Frontend Routing', function () {
should.exist(res.headers.date);
$('title').text().should.equal('Not finished yet');
$('meta[name="description"]').attr('content').should.equal('meta description for draft post');
// @TODO: use theme from fixtures and don't rely on content/themes/casper
// $('.content .post').length.should.equal(1);
// $('.poweredby').text().should.equal('Proudly published with Ghost');

View File

@ -809,6 +809,11 @@ DataGenerator.forKnex = (function () {
id: ObjectId.generate(),
post_id: DataGenerator.Content.posts[2].id,
meta_description: 'test stuff'
},
{
id: ObjectId.generate(),
post_id: DataGenerator.Content.posts[3].id,
meta_description: 'meta description for draft post'
}
];