0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-13 22:41:32 -05:00

Sitemaps correctly filter draft posts

fixes #4612

- adds missing line of code to remove draft posts
- adds tests to check drafts aren't added
This commit is contained in:
Hannah Wolfe 2014-12-09 17:12:00 +00:00
parent 93c5ff3e04
commit 2ef77d69de
2 changed files with 41 additions and 0 deletions

View file

@ -118,6 +118,10 @@ _.extend(SiteMapManager.prototype, {
return;
}
if (post.get('status') !== 'published') {
return;
}
this.posts.addUrl(post.toJSON());
},

View file

@ -157,6 +157,25 @@ describe('Sitemap', function () {
}).catch(done);
});
it('doesn\'t add draft pages', function (done) {
var manager = makeStubManager(),
fake = {
toJSON: sandbox.stub().returns({
status: 'draft'
}),
get: sandbox.stub().returns('draft'),
updated: sandbox.stub().returns('draft')
};
manager.init().then(function () {
manager.pageAdded(fake);
manager.pages.addUrl.called.should.equal(false);
done();
}).catch(done);
});
it('deletes pages that were unpublished', function (done) {
var manager = makeStubManager(),
fake = {
@ -225,6 +244,24 @@ describe('Sitemap', function () {
}).catch(done);
});
it('doesn\'t add draft posts', function (done) {
var manager = makeStubManager(),
fake = {
toJSON: sandbox.stub().returns({
status: 'draft'
}),
get: sandbox.stub().returns('draft'),
updated: sandbox.stub().returns('draft')
};
manager.init().then(function () {
manager.postAdded(fake);
manager.posts.addUrl.called.should.equal(false);
done();
}).catch(done);
});
it('deletes posts that were unpublished', function (done) {
var manager = makeStubManager(),
fake = {