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:
parent
93c5ff3e04
commit
2ef77d69de
2 changed files with 41 additions and 0 deletions
|
@ -118,6 +118,10 @@ _.extend(SiteMapManager.prototype, {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (post.get('status') !== 'published') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.posts.addUrl(post.toJSON());
|
this.posts.addUrl(post.toJSON());
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -157,6 +157,25 @@ describe('Sitemap', function () {
|
||||||
}).catch(done);
|
}).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) {
|
it('deletes pages that were unpublished', function (done) {
|
||||||
var manager = makeStubManager(),
|
var manager = makeStubManager(),
|
||||||
fake = {
|
fake = {
|
||||||
|
@ -225,6 +244,24 @@ describe('Sitemap', function () {
|
||||||
}).catch(done);
|
}).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) {
|
it('deletes posts that were unpublished', function (done) {
|
||||||
var manager = makeStubManager(),
|
var manager = makeStubManager(),
|
||||||
fake = {
|
fake = {
|
||||||
|
|
Loading…
Reference in a new issue