Merge pull request #6015 from vdemedes/fix-missing-post-title
Replace missing title with "(Untitled)" when creating a post via API
This commit is contained in:
commit
65cb9cd9e8
@ -115,6 +115,7 @@ Post = ghostBookshelf.Model.extend({
|
||||
saving: function saving(model, attr, options) {
|
||||
var self = this,
|
||||
tagsToCheck,
|
||||
title,
|
||||
i;
|
||||
|
||||
options = options || {};
|
||||
@ -138,7 +139,8 @@ Post = ghostBookshelf.Model.extend({
|
||||
|
||||
// disabling sanitization until we can implement a better version
|
||||
// this.set('title', this.sanitize('title').trim());
|
||||
this.set('title', this.get('title').trim());
|
||||
title = this.get('title') || '(Untitled)';
|
||||
this.set('title', title.trim());
|
||||
|
||||
// ### Business logic for published_at and published_by
|
||||
// If the current status is 'published' and published_at is not set, set it to now
|
||||
|
@ -653,6 +653,17 @@ describe('Post Model', function () {
|
||||
}).catch(done);
|
||||
});
|
||||
|
||||
it('can add default title, if it\'s missing', function (done) {
|
||||
PostModel.add({
|
||||
markdown: 'Content'
|
||||
}, context).then(function (newPost) {
|
||||
should.exist(newPost);
|
||||
newPost.get('title').should.equal('(Untitled)');
|
||||
|
||||
done();
|
||||
}).catch(done);
|
||||
});
|
||||
|
||||
it('can trim title', function (done) {
|
||||
var untrimmedCreateTitle = ' test trimmed create title ',
|
||||
untrimmedUpdateTitle = ' test trimmed update title ',
|
||||
|
Loading…
Reference in New Issue
Block a user