From e106c6dc1c5cc9ca363d94712eaece09ddac3b5b Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Fri, 20 Mar 2020 11:16:59 +0000 Subject: [PATCH] Added acceptance tests for private blogging - Test that the basic routes are working --- .../default_routes_spec.js | 46 +++++++++++++++---- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/core/test/frontend-acceptance/default_routes_spec.js b/core/test/frontend-acceptance/default_routes_spec.js index b0bff9753f..743064bac0 100644 --- a/core/test/frontend-acceptance/default_routes_spec.js +++ b/core/test/frontend-acceptance/default_routes_spec.js @@ -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(//); + doEnd(done)(err, res); + }); + }); + }); });