mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-23 19:02:29 +03:00
Merge pull request #161 from tgriesser/published_at
Setting published_at when post changes to published status.
This commit is contained in:
commit
49f6cc92d4
@ -29,12 +29,12 @@
|
|||||||
t.string('status');
|
t.string('status');
|
||||||
t.string('language');
|
t.string('language');
|
||||||
t.integer('author_id');
|
t.integer('author_id');
|
||||||
t.date('created_at');
|
t.dateTime('created_at');
|
||||||
t.integer('created_by');
|
t.integer('created_by');
|
||||||
t.date('updated_at');
|
t.dateTime('updated_at').nullable();
|
||||||
t.integer('updated_by');
|
t.integer('updated_by').nullable();
|
||||||
t.date('published_at');
|
t.dateTime('published_at').nullable();
|
||||||
t.integer('published_by');
|
t.integer('published_by').nullable();
|
||||||
}),
|
}),
|
||||||
|
|
||||||
knex.Schema.createTable('users', function (t) {
|
knex.Schema.createTable('users', function (t) {
|
||||||
@ -47,9 +47,9 @@
|
|||||||
t.string('cover_picture');
|
t.string('cover_picture');
|
||||||
t.text('bio');
|
t.text('bio');
|
||||||
t.string('url');
|
t.string('url');
|
||||||
t.date('created_at');
|
t.dateTime('created_at');
|
||||||
t.integer('created_by');
|
t.integer('created_by');
|
||||||
t.date('updated_at');
|
t.dateTime('updated_at');
|
||||||
t.integer('updated_by');
|
t.integer('updated_by');
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@ -91,9 +91,9 @@
|
|||||||
t.string('key').unique();
|
t.string('key').unique();
|
||||||
t.text('value');
|
t.text('value');
|
||||||
t.string('type');
|
t.string('type');
|
||||||
t.date('created_at');
|
t.dateTime('created_at');
|
||||||
t.integer('created_by');
|
t.integer('created_by');
|
||||||
t.date('updated_at');
|
t.dateTime('updated_at');
|
||||||
t.integer('updated_by');
|
t.integer('updated_by');
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -36,6 +36,12 @@
|
|||||||
}
|
}
|
||||||
this.set('content_html', converter.makeHtml(this.get('content')));
|
this.set('content_html', converter.makeHtml(this.get('content')));
|
||||||
|
|
||||||
|
if (this.hasChanged('status') && this.get('status') === 'published') {
|
||||||
|
this.set('published_at', new Date());
|
||||||
|
// This will need to go elsewhere in the API layer.
|
||||||
|
this.set('published_by', 1);
|
||||||
|
}
|
||||||
|
|
||||||
// refactoring of ghost required in order to make these details available here
|
// refactoring of ghost required in order to make these details available here
|
||||||
// this.set('language', this.get('language') || ghost.config().defaultLang);
|
// this.set('language', this.get('language') || ghost.config().defaultLang);
|
||||||
// this.set('status', this.get('status') || ghost.statuses().draft);
|
// this.set('status', this.get('status') || ghost.statuses().draft);
|
||||||
|
@ -79,6 +79,10 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
PostModel.add(newPost).then(function (createdPost) {
|
PostModel.add(newPost).then(function (createdPost) {
|
||||||
|
|
||||||
|
return new PostModel({id: createdPost.id}).fetch();
|
||||||
|
|
||||||
|
}).then(function (createdPost) {
|
||||||
should.exist(createdPost);
|
should.exist(createdPost);
|
||||||
|
|
||||||
createdPost.has('uuid').should.equal(true);
|
createdPost.has('uuid').should.equal(true);
|
||||||
@ -86,9 +90,16 @@
|
|||||||
createdPost.get('title').should.equal(newPost.title, "title is correct");
|
createdPost.get('title').should.equal(newPost.title, "title is correct");
|
||||||
createdPost.get('content').should.equal(newPost.content, "content is correct");
|
createdPost.get('content').should.equal(newPost.content, "content is correct");
|
||||||
createdPost.get('slug').should.equal(newPost.title.toLowerCase().replace(/ /g, '-'), 'slug is correct');
|
createdPost.get('slug').should.equal(newPost.title.toLowerCase().replace(/ /g, '-'), 'slug is correct');
|
||||||
|
should.equal(createdPost.get('published_at'), null);
|
||||||
|
|
||||||
|
// Set the status to published to check that `published_at` is set.
|
||||||
|
return createdPost.save({status: 'published'});
|
||||||
|
|
||||||
|
}).then(function(publishedPost) {
|
||||||
|
publishedPost.get('published_at').should.be.instanceOf(Date);
|
||||||
done();
|
done();
|
||||||
}).then(null, done);
|
}).then(null, done);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can delete', function (done) {
|
it('can delete', function (done) {
|
||||||
|
Loading…
Reference in New Issue
Block a user