mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-27 22:49:56 -05:00
🐛 Fixed excerpt
property being missing if plaintext
is NULL or ""
closes https://github.com/TryGhost/Ghost/issues/10558 - added conditional to explicitly set `excerpt` to `null` in the API output serializer when a post has no `plaintext` or `custom_excerpt` value
This commit is contained in:
parent
2b34327544
commit
5a7356de5b
2 changed files with 14 additions and 0 deletions
|
@ -8,6 +8,8 @@ module.exports.forPost = (frame, model, attrs) => {
|
|||
|
||||
if (plaintext) {
|
||||
attrs.excerpt = plaintext.substring(0, 500);
|
||||
} else {
|
||||
attrs.excerpt = null;
|
||||
}
|
||||
} else {
|
||||
attrs.excerpt = attrs.custom_excerpt;
|
||||
|
|
|
@ -33,5 +33,17 @@ describe('Unit: v2/utils/serializers/output/utils/extra-attrs', () => {
|
|||
|
||||
attrs.excerpt.should.eql(new Array(501).join('A'));
|
||||
});
|
||||
|
||||
it('has excerpt when plaintext is null', () => {
|
||||
model.get.withArgs('plaintext').returns(null);
|
||||
|
||||
const attrs = {};
|
||||
|
||||
extraAttrsUtil.forPost(frame, model, attrs);
|
||||
model.get.called.should.be.true();
|
||||
|
||||
attrs.should.have.property('excerpt');
|
||||
(attrs.excerpt === null).should.be.true();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue