Merge pull request #4614 from ErisDS/issue-4612

Sitemaps correctly filter draft posts
This commit is contained in:
Sebastian Gierlinger 2014-12-09 19:36:19 +01:00
commit 251d2e0ecf
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 = {