Added acceptance tests for private blogging

- Test that the basic routes are working
This commit is contained in:
Hannah Wolfe 2020-03-20 11:16:59 +00:00
parent 297c773f2a
commit e106c6dc1c

View File

@ -36,16 +36,6 @@ describe('Default Frontend routing', function () {
};
}
function addPosts(done) {
testUtils.clearData().then(function () {
return testUtils.initData();
}).then(function () {
return testUtils.fixtures.insertPostsAndTags();
}).then(function () {
done();
});
}
afterEach(function () {
sinon.restore();
});
@ -404,4 +394,40 @@ describe('Default Frontend routing', function () {
});
});
});
describe('Private Blogging', function () {
beforeEach(function () {
sinon.stub(settingsCache, 'get').callsFake(function (key, options) {
if (key === 'is_private') {
return true;
}
return origCache.get(key, options);
});
});
it('/ should redirect to /private/', function (done) {
request.get('/')
.expect('Location', '/private/?r=%2F')
.expect(302)
.end(doEnd(done));
});
it('/welcome/ should redirect to /private/', function (done) {
request.get('/welcome/')
.expect('Location', '/private/?r=%2Fwelcome%2F')
.expect(302)
.end(doEnd(done));
});
it('should still serve private RSS feed', function (done) {
request.get(`/${settingsCache.get('public_hash')}/rss/`)
.expect(200)
.expect('Cache-Control', testUtils.cacheRules.private)
.expect('Content-Type', 'text/xml; charset=utf-8')
.end(function (err, res) {
res.text.should.match(/<!\[CDATA\[Welcome to Ghost\]\]>/);
doEnd(done)(err, res);
});
});
});
});