diff --git a/core/server/data/sitemap/manager.js b/core/server/data/sitemap/manager.js index f6300e8039..93f213ac27 100644 --- a/core/server/data/sitemap/manager.js +++ b/core/server/data/sitemap/manager.js @@ -118,6 +118,10 @@ _.extend(SiteMapManager.prototype, { return; } + if (post.get('status') !== 'published') { + return; + } + this.posts.addUrl(post.toJSON()); }, diff --git a/core/test/integration/sitemap_spec.js b/core/test/integration/sitemap_spec.js index f893b4e962..793bb2a90f 100644 --- a/core/test/integration/sitemap_spec.js +++ b/core/test/integration/sitemap_spec.js @@ -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 = {