Moved routing helpers to rendering service

- The helpers folder was full of things used for rendering pages
- It belongs as its own service so that we can see what it really does
This commit is contained in:
Hannah Wolfe 2022-04-05 19:31:49 +01:00
parent c902d91c81
commit 08479f3816
No known key found for this signature in database
GPG Key ID: AB586C3B5AE5C037
32 changed files with 109 additions and 118 deletions

View File

@ -8,7 +8,7 @@ const errors = require('@tryghost/errors');
// Dirty requires
const urlService = require('../../../../server/services/url');
const dataService = require('../../../services/data');
const helpers = require('../../../services/routing/helpers');
const renderer = require('../../../services/rendering');
const templateName = 'amp';
const messages = {
@ -32,7 +32,7 @@ function _renderer(req, res, next) {
}
// Render Call
return helpers.renderer(req, res, body);
return renderer.renderer(req, res, body);
}
// This here is a controller.

View File

@ -2,7 +2,7 @@ const path = require('path');
const express = require('../../../../shared/express');
const middleware = require('./middleware');
const bodyParser = require('body-parser');
const routing = require('../../../services/routing');
const renderer = require('../../../services/rendering');
const web = require('../../../../server/web');
const templateName = 'private';
const privateRouter = express.Router(templateName);
@ -23,7 +23,7 @@ function _renderer(req, res) {
}
// Render Call
return routing.helpers.renderer(req, res, data);
return renderer.renderer(req, res, data);
}
// password-protected frontend route

View File

@ -1,5 +1,5 @@
const _ = require('lodash');
const {prepareContextResource} = require('../../proxy');
const {prepareContextResource} = require('../proxy');
/**
* @description Formats API response into handlebars/theme format.

View File

@ -1,4 +1,4 @@
const debug = require('@tryghost/debug')('services:routing:helpers:render-entries');
const debug = require('@tryghost/debug')('services:routing:renderer:render-entries');
const formatResponse = require('./format-response');
const renderer = require('./renderer');

View File

@ -1,4 +1,4 @@
const debug = require('@tryghost/debug')('services:routing:helpers:render-post');
const debug = require('@tryghost/debug')('services:routing:renderer:render-post');
const formatResponse = require('./format-response');
const renderer = require('./renderer');
/**

View File

@ -1,4 +1,4 @@
const debug = require('@tryghost/debug')('services:routing:helpers:renderer');
const debug = require('@tryghost/debug')('services:routing:renderer:renderer');
const setContext = require('./context');
const templates = require('./templates');

View File

@ -6,8 +6,8 @@ const _ = require('lodash');
const path = require('path');
const url = require('url');
const config = require('../../../../shared/config');
const themeEngine = require('../../theme-engine');
const config = require('../../../shared/config');
const themeEngine = require('../theme-engine');
const _private = {};
/**

View File

@ -30,7 +30,7 @@ class CollectionRouter extends ParentRouter {
value: object.permalink
};
// @NOTE: see helpers/templates - we use unshift to prepend the templates
// @NOTE: see renderer/templates - we use unshift to prepend the templates
this.templates = (object.templates || []).reverse();
this.filter = object.filter;

View File

@ -5,7 +5,7 @@ const errors = require('@tryghost/errors');
const security = require('@tryghost/security');
const themeEngine = require('../../theme-engine');
const dataService = require('../../data');
const helpers = require('../helpers');
const renderer = require('../../rendering');
const messages = {
pageNotFound: 'Page not found.'
@ -61,16 +61,15 @@ module.exports = function channelController(req, res, next) {
}
// Format data 1
// @TODO: See helpers/secure for explanation.
helpers.secure(req, result.posts);
// @TODO: See renderer/secure for explanation.
renderer.secure(req, result.posts);
// @TODO: See helpers/secure for explanation.
// @TODO: See renderer/secure for explanation.
_.each(result.data, function (data) {
helpers.secure(req, data);
renderer.secure(req, data);
});
const renderer = helpers.renderEntries(req, res);
return renderer(result);
return renderer.renderEntries(req, res)(result);
})
.catch(helpers.handleError(next));
.catch(renderer.handleError(next));
};

View File

@ -5,7 +5,7 @@ const errors = require('@tryghost/errors');
const security = require('@tryghost/security');
const {routerManager} = require('../');
const themeEngine = require('../../theme-engine');
const helpers = require('../helpers');
const renderer = require('../../rendering');
const dataService = require('../../data');
const messages = {
@ -81,16 +81,15 @@ module.exports = function collectionController(req, res, next) {
});
// Format data 1
// @TODO: See helpers/secure for explanation.
helpers.secure(req, result.posts);
// @TODO: See renderer/secure for explanation.
renderer.secure(req, result.posts);
// @TODO: See helpers/secure for explanation.
// @TODO: See renderer/secure for explanation.
_.each(result.data, function (data) {
helpers.secure(req, data);
renderer.secure(req, data);
});
const renderer = helpers.renderEntries(req, res);
return renderer(result);
return renderer.renderEntries(req, res)(result);
})
.catch(helpers.handleError(next));
.catch(renderer.handleError(next));
};

View File

@ -2,7 +2,7 @@ const debug = require('@tryghost/debug')('services:routing:controllers:emailpost
const config = require('../../../../shared/config');
const {routerManager} = require('../');
const urlUtils = require('../../../../shared/url-utils');
const helpers = require('../helpers');
const renderer = require('../../rendering');
/**
* @description Email Post Controller.
@ -55,11 +55,10 @@ module.exports = function emailPostController(req, res, next) {
post.access = !!post.html;
}
// @TODO: See helpers/secure
helpers.secure(req, post);
// @TODO: See renderer/secure
renderer.secure(req, post);
const renderer = helpers.renderEntry(req, res);
return renderer(post);
return renderer.renderEntry(req, res)(post);
})
.catch(helpers.handleError(next));
.catch(renderer.handleError(next));
};

View File

@ -4,7 +4,7 @@ const config = require('../../../../shared/config');
const {routerManager} = require('../');
const urlUtils = require('../../../../shared/url-utils');
const dataService = require('../../data');
const helpers = require('../helpers');
const renderer = require('../../rendering');
/**
* @description Entry controller.
@ -84,10 +84,9 @@ module.exports = function entryController(req, res, next) {
}));
}
helpers.secure(req, entry);
renderer.secure(req, entry);
const renderer = helpers.renderEntry(req, res);
return renderer(entry);
return renderer.renderEntry(req, res)(entry);
})
.catch(helpers.handleError(next));
.catch(renderer.handleError(next));
};

View File

@ -2,7 +2,7 @@ const debug = require('@tryghost/debug')('services:routing:controllers:preview')
const config = require('../../../../shared/config');
const {routerManager} = require('../');
const urlUtils = require('../../../../shared/url-utils');
const helpers = require('../helpers');
const renderer = require('../../rendering');
/**
* @description Preview Controller.
@ -57,11 +57,10 @@ module.exports = function previewController(req, res, next) {
post.access = !!post.html;
}
// @TODO: See helpers/secure
helpers.secure(req, post);
// @TODO: See renderer/secure
renderer.secure(req, post);
const renderer = helpers.renderEntry(req, res);
return renderer(post);
return renderer.renderEntry(req, res)(post);
})
.catch(helpers.handleError(next));
.catch(renderer.handleError(next));
};

View File

@ -4,7 +4,7 @@ const url = require('url');
const security = require('@tryghost/security');
const settingsCache = require('../../../../shared/settings-cache');
const rssService = require('../../rss');
const helpers = require('../helpers');
const renderer = require('../../rendering');
const dataService = require('../../data');
// @TODO: is this really correct? Should we be using meta data title?
@ -48,5 +48,5 @@ module.exports = function rssController(req, res, next) {
.then(function (data) {
return rssService.render(res, baseUrl, data);
})
.catch(helpers.handleError(next));
.catch(renderer.handleError(next));
};

View File

@ -1,7 +1,7 @@
const _ = require('lodash');
const Promise = require('bluebird');
const debug = require('@tryghost/debug')('services:routing:controllers:static');
const helpers = require('../helpers');
const renderer = require('../../rendering');
function processQuery(query, locals) {
const api = require('../../proxy').api[locals.apiVersion];
@ -60,12 +60,12 @@ module.exports = function staticController(req, res, next) {
});
}
// @TODO: See helpers/secure for more context.
// @TODO: See renderer/secure for more context.
_.each(response.data, function (data) {
helpers.secure(req, data);
renderer.secure(req, data);
});
helpers.renderer(req, res, helpers.formatResponse.entries(response));
renderer.renderer(req, res, renderer.formatResponse.entries(response));
})
.catch(helpers.handleError(next));
.catch(renderer.handleError(next));
};

View File

@ -1,7 +1,7 @@
const debug = require('@tryghost/debug')('services:routing:controllers:unsubscribe');
const path = require('path');
const megaService = require('../../../../server/services/mega');
const helpers = require('../../../services/routing/helpers');
const renderer = require('../../rendering');
module.exports = async function unsubscribeController(req, res) {
debug('unsubscribeController');
@ -22,5 +22,5 @@ module.exports = async function unsubscribeController(req, res) {
defaultTemplate: path.resolve(__dirname, '../../../views/', templateName)
};
return helpers.renderer(req, res, data);
return renderer.renderer(req, res, data);
};

View File

@ -7,9 +7,5 @@ module.exports = {
get registry() {
return registry;
},
get helpers() {
return require('./helpers');
}
};

View File

@ -4,7 +4,7 @@ const tpl = require('@tryghost/tpl');
const sentry = require('../../../shared/sentry');
const config = require('../../../shared/config');
const helpers = require('../../services/routing/helpers');
const renderer = require('../../services/rendering');
// @TODO: make this properly shared code
const {prepareError, prepareStack} = require('@tryghost/mw-error-handler');
@ -55,7 +55,7 @@ const themeErrorRenderer = (err, req, res, next) => {
// Template
// @TODO: very dirty !!!!!!
helpers.templates.setTemplate(req, res);
renderer.templates.setTemplate(req, res);
// It can be that something went wrong with the theme or otherwise loading handlebars
// This ensures that no matter what res.render will work here

View File

@ -4,7 +4,7 @@ const sinon = require('sinon');
const path = require('path');
const ampController = require('../../../../../core/frontend/apps/amp/lib/router');
const urlService = require('../../../../../core/server/services/url');
const helpers = require('../../../../../core/frontend/services/routing/helpers');
const renderer = require('../../../../../core/frontend/services/rendering');
const dataService = require('../../../../../core/frontend/services/data');
const testUtils = require('../../../../utils');
const configUtils = require('../../../../utils/configUtils');
@ -27,7 +27,7 @@ describe('Unit - apps/amp/lib/router', function () {
beforeEach(function () {
rendererStub = sinon.stub();
sinon.stub(helpers, 'renderer').get(function () {
sinon.stub(renderer, 'renderer').get(function () {
return rendererStub;
});
@ -59,7 +59,7 @@ describe('Unit - apps/amp/lib/router', function () {
describe('fn: renderer', function () {
it('should render default amp page when theme has no amp template', function (done) {
helpers.renderer.callsFake(function (_req, _res, data) {
renderer.renderer.callsFake(function (_req, _res, data) {
_res.routerOptions.defaultTemplate.should.eql(defaultPath);
data.should.eql({post: {title: 'test'}});
done();
@ -73,7 +73,7 @@ describe('Unit - apps/amp/lib/router', function () {
ampController.renderer(req, res, function (err) {
(err instanceof errors.NotFoundError).should.be.true();
helpers.renderer.called.should.be.false();
renderer.renderer.called.should.be.false();
done();
});
});
@ -87,7 +87,7 @@ describe('Unit - apps/amp/lib/router', function () {
ampController.renderer(req, res, function (err) {
(err instanceof errors.NotFoundError).should.be.true();
helpers.renderer.called.should.be.false();
renderer.renderer.called.should.be.false();
done();
});
});

View File

@ -1,9 +1,9 @@
const should = require('should');
const sinon = require('sinon');
const _ = require('lodash');
const testUtils = require('../../../../../utils');
const helpers = require('../../../../../../core/frontend/services/routing/helpers');
const labs = require('../../../../../../core/shared/labs');
const testUtils = require('../../../../utils');
const renderer = require('../../../../../core/frontend/services/rendering');
const labs = require('../../../../../core/shared/labs');
describe('Contexts', function () {
let req;
@ -33,14 +33,14 @@ describe('Contexts', function () {
res = {};
data = {};
helpers.context(req, res, data);
renderer.context(req, res, data);
should.exist(res.locals.context);
res.locals.context.should.be.an.Array().with.lengthOf(0);
});
it('should return empty array with no error with basic parameters', function () {
helpers.context(req, res, data);
renderer.context(req, res, data);
should.exist(res.locals.context);
res.locals.context.should.be.an.Array().with.lengthOf(0);
@ -52,7 +52,7 @@ describe('Contexts', function () {
res.locals.relativeUrl = '/does/not/matter/';
res.routerOptions.context = ['index'];
helpers.context(req, res, data);
renderer.context(req, res, data);
should.exist(res.locals.context);
res.locals.context.should.be.an.Array().with.lengthOf(1);
@ -64,7 +64,7 @@ describe('Contexts', function () {
res.routerOptions.context = ['index'];
// Execute test
helpers.context(req, res, data);
renderer.context(req, res, data);
// Check context
should.exist(res.locals.context);
@ -78,7 +78,7 @@ describe('Contexts', function () {
res.routerOptions.context = [];
// Execute test
helpers.context(req, res, data);
renderer.context(req, res, data);
// Check context
should.exist(res.locals.context);
@ -90,7 +90,7 @@ describe('Contexts', function () {
res.locals.relativeUrl = '/page/2/';
res.routerOptions.context = ['index'];
helpers.context(req, res, data);
renderer.context(req, res, data);
should.exist(res.locals.context);
res.locals.context.should.be.an.Array().with.lengthOf(1);
@ -102,7 +102,7 @@ describe('Contexts', function () {
req.params.page = 2;
res.routerOptions.context = ['index'];
helpers.context(req, res, data);
renderer.context(req, res, data);
should.exist(res.locals.context);
res.locals.context.should.be.an.Array().with.lengthOf(2);
@ -116,7 +116,7 @@ describe('Contexts', function () {
res.locals.relativeUrl = '/tag/getting-started/';
res.routerOptions.context = ['tag'];
helpers.context(req, res, data);
renderer.context(req, res, data);
should.exist(res.locals.context);
res.locals.context.should.be.an.Array().with.lengthOf(1);
@ -127,7 +127,7 @@ describe('Contexts', function () {
res.locals.relativeUrl = '/tag/getting-started/';
res.routerOptions.context = [];
helpers.context(req, res, data);
renderer.context(req, res, data);
should.exist(res.locals.context);
res.locals.context.should.be.an.Array().with.lengthOf(0);
@ -137,7 +137,7 @@ describe('Contexts', function () {
res.locals.relativeUrl = '/tag/getting-started/page/2/';
res.routerOptions.context = ['tag'];
helpers.context(req, res, data);
renderer.context(req, res, data);
should.exist(res.locals.context);
res.locals.context.should.be.an.Array().with.lengthOf(1);
@ -149,7 +149,7 @@ describe('Contexts', function () {
req.params.page = 2;
res.routerOptions.context = ['tag'];
helpers.context(req, res, data);
renderer.context(req, res, data);
should.exist(res.locals.context);
res.locals.context.should.be.an.Array().with.lengthOf(2);
@ -163,7 +163,7 @@ describe('Contexts', function () {
res.locals.relativeUrl = '/author/pat/';
res.routerOptions.context = ['author'];
helpers.context(req, res, data);
renderer.context(req, res, data);
should.exist(res.locals.context);
res.locals.context.should.be.an.Array().with.lengthOf(1);
@ -174,7 +174,7 @@ describe('Contexts', function () {
res.locals.relativeUrl = '/author/pat/';
res.routerOptions.context = [];
helpers.context(req, res, data);
renderer.context(req, res, data);
should.exist(res.locals.context);
res.locals.context.should.be.an.Array().with.lengthOf(0);
@ -184,7 +184,7 @@ describe('Contexts', function () {
res.locals.relativeUrl = '/author/pat/page/2/';
res.routerOptions.context = ['author'];
helpers.context(req, res, data);
renderer.context(req, res, data);
should.exist(res.locals.context);
res.locals.context.should.be.an.Array().with.lengthOf(1);
@ -196,7 +196,7 @@ describe('Contexts', function () {
req.params.page = 2;
res.routerOptions.context = ['author'];
helpers.context(req, res, data);
renderer.context(req, res, data);
should.exist(res.locals.context);
res.locals.context.should.be.an.Array().with.lengthOf(2);
@ -210,7 +210,7 @@ describe('Contexts', function () {
res.locals.relativeUrl = 'anything';
res.routerOptions.context = ['custom-context', 'test'];
helpers.context(req, res, data);
renderer.context(req, res, data);
should.exist(res.locals.context);
res.locals.context.should.be.an.Array().with.lengthOf(2);
@ -224,7 +224,7 @@ describe('Contexts', function () {
res.locals.relativeUrl = '/welcome-to-ghost/';
res.routerOptions.context = ['post'];
helpers.context(req, res, data);
renderer.context(req, res, data);
should.exist(res.locals.context);
res.locals.context.should.be.an.Array().with.lengthOf(1);
@ -237,7 +237,7 @@ describe('Contexts', function () {
res.locals.relativeUrl = '/private/?r=';
delete res.routerOptions;
helpers.context(req, res, data);
renderer.context(req, res, data);
should.exist(res.locals.context);
res.locals.context.should.be.an.Array().with.lengthOf(1);
@ -252,7 +252,7 @@ describe('Contexts', function () {
data.post = testUtils.DataGenerator.forKnex.createPost();
delete res.routerOptions;
helpers.context(req, res, data);
renderer.context(req, res, data);
should.exist(res.locals.context);
res.locals.context.should.be.an.Array().with.lengthOf(1);
@ -266,7 +266,7 @@ describe('Contexts', function () {
data.post = testUtils.DataGenerator.forKnex.createPost();
delete res.routerOptions;
helpers.context(req, res, data);
renderer.context(req, res, data);
should.exist(res.locals.context);
res.locals.context.should.be.an.Array().with.lengthOf(2);
@ -279,7 +279,7 @@ describe('Contexts', function () {
data.page = testUtils.DataGenerator.forKnex.createPost({page: true});
delete res.routerOptions;
helpers.context(req, res, data);
renderer.context(req, res, data);
should.exist(res.locals.context);
res.locals.context.should.be.an.Array().with.lengthOf(2);

View File

@ -1,7 +1,7 @@
const should = require('should');
const sinon = require('sinon');
const errors = require('@tryghost/errors');
const helpers = require('../../../../../../core/frontend/services/routing/helpers');
const helpers = require('../../../../../core/frontend/services/rendering');
describe('handleError', function () {
let next;

View File

@ -1,7 +1,7 @@
const should = require('should');
const testUtils = require('../../../../../utils');
const helpers = require('../../../../../../core/frontend/services/routing/helpers');
const {SafeString} = require('../../../../../../core/frontend/services/handlebars');
const testUtils = require('../../../../utils');
const helpers = require('../../../../../core/frontend/services/rendering');
const {SafeString} = require('../../../../../core/frontend/services/handlebars');
describe('Unit - services/routing/helpers/format-response', function () {
let posts;

View File

@ -1,8 +1,8 @@
const should = require('should');
const sinon = require('sinon');
const rewire = require('rewire');
const templates = rewire('../../../../../../core/frontend/services/routing/helpers/templates');
const themeEngine = require('../../../../../../core/frontend/services/theme-engine');
const templates = rewire('../../../../../core/frontend/services/rendering/templates');
const themeEngine = require('../../../../../core/frontend/services/theme-engine');
describe('templates', function () {
let getActiveThemeStub;

View File

@ -5,7 +5,7 @@ const testUtils = require('../../../../../utils');
const security = require('@tryghost/security');
const themeEngine = require('../../../../../../core/frontend/services/theme-engine');
const controllers = require('../../../../../../core/frontend/services/routing/controllers');
const helpers = require('../../../../../../core/frontend/services/routing/helpers');
const renderer = require('../../../../../../core/frontend/services/rendering');
const dataService = require('../../../../../../core/frontend/services/data');
function failTest(done) {
@ -41,7 +41,7 @@ describe('Unit - services/routing/controllers/channel', function () {
sinon.stub(security.string, 'safe').returns('safe');
sinon.stub(helpers, 'secure').get(function () {
sinon.stub(renderer, 'secure').get(function () {
return secureStub;
});
@ -53,7 +53,7 @@ describe('Unit - services/routing/controllers/channel', function () {
}
});
sinon.stub(helpers, 'renderEntries').returns(renderStub);
sinon.stub(renderer, 'renderEntries').returns(renderStub);
req = {
path: '/',

View File

@ -6,7 +6,7 @@ const security = require('@tryghost/security');
const themeEngine = require('../../../../../../core/frontend/services/theme-engine');
const routerManager = require('../../../../../../core/frontend/services/routing/').routerManager;
const controllers = require('../../../../../../core/frontend/services/routing/controllers');
const helpers = require('../../../../../../core/frontend/services/routing/helpers');
const renderer = require('../../../../../../core/frontend/services/rendering');
const dataService = require('../../../../../../core/frontend/services/data');
function failTest(done) {
@ -43,7 +43,7 @@ describe('Unit - services/routing/controllers/collection', function () {
sinon.stub(security.string, 'safe').returns('safe');
sinon.stub(helpers, 'secure').get(function () {
sinon.stub(renderer, 'secure').get(function () {
return secureStub;
});
@ -55,7 +55,7 @@ describe('Unit - services/routing/controllers/collection', function () {
}
});
sinon.stub(helpers, 'renderEntries').returns(renderStub);
sinon.stub(renderer, 'renderEntries').returns(renderStub);
ownsStub = sinon.stub(routerManager, 'owns');
ownsStub.withArgs('identifier', posts[0].id).returns(true);

View File

@ -5,7 +5,7 @@ const configUtils = require('../../../../../utils/configUtils');
const urlUtils = require('../../../../../../core/shared/url-utils');
const routerManager = require('../../../../../../core/frontend/services/routing/').routerManager;
const controllers = require('../../../../../../core/frontend/services/routing/controllers');
const helpers = require('../../../../../../core/frontend/services/routing/helpers');
const renderer = require('../../../../../../core/frontend/services/rendering');
const dataService = require('../../../../../../core/frontend/services/data');
const EDITOR_URL = `/#/editor/post/`;
@ -32,11 +32,11 @@ describe('Unit - services/routing/controllers/entry', function () {
return entryLookUpStub;
});
sinon.stub(helpers, 'secure').get(function () {
sinon.stub(renderer, 'secure').get(function () {
return secureStub;
});
sinon.stub(helpers, 'renderEntry').get(function () {
sinon.stub(renderer, 'renderEntry').get(function () {
return renderStub;
});

View File

@ -5,7 +5,7 @@ const testUtils = require('../../../../../utils');
const configUtils = require('../../../../../utils/configUtils');
const api = require('../../../../../../core/server/api').canary;
const controllers = require('../../../../../../core/frontend/services/routing/controllers');
const helpers = require('../../../../../../core/frontend/services/routing/helpers');
const renderer = require('../../../../../../core/frontend/services/rendering');
const urlService = require('../../../../../../core/server/services/url');
const urlUtils = require('../../../../../../core/shared/url-utils');
@ -64,12 +64,12 @@ describe('Unit - services/routing/controllers/preview', function () {
sinon.stub(urlUtils, 'redirect301');
sinon.stub(urlService, 'getUrlByResourceId');
sinon.stub(helpers, 'secure').get(function () {
sinon.stub(renderer, 'secure').get(function () {
return secureStub;
});
renderStub = sinon.stub();
sinon.stub(helpers, 'renderEntry').get(function () {
sinon.stub(renderer, 'renderEntry').get(function () {
return function () {
return renderStub;
};

View File

@ -1,10 +1,10 @@
const should = require('should');
const sinon = require('sinon');
const testUtils = require('../../../../../utils');
const API_VERSION = 'canary';
const api = require('../../../../../../core/server/api')[API_VERSION];
const themeEngine = require('../../../../../../core/frontend/services/theme-engine');
const helpers = require('../../../../../../core/frontend/services/routing/helpers');
const renderer = require('../../../../../../core/frontend/services/rendering');
const controllers = require('../../../../../../core/frontend/services/routing/controllers');
function failTest(done) {
@ -40,11 +40,11 @@ describe('Unit - services/routing/controllers/static', function () {
};
});
sinon.stub(helpers, 'secure').get(function () {
sinon.stub(renderer, 'secure').get(function () {
return secureStub;
});
sinon.stub(helpers, 'handleError').get(function () {
sinon.stub(renderer, 'handleError').get(function () {
return handleErrorStub;
});
@ -56,11 +56,11 @@ describe('Unit - services/routing/controllers/static', function () {
}
});
sinon.stub(helpers, 'renderer').get(function () {
sinon.stub(renderer, 'renderer').get(function () {
return renderStub;
});
sinon.stub(helpers, 'formatResponse').get(function () {
sinon.stub(renderer, 'formatResponse').get(function () {
return formatResponseStub;
});
@ -85,10 +85,10 @@ describe('Unit - services/routing/controllers/static', function () {
});
it('no extra data to fetch', function (done) {
helpers.renderer.callsFake(function () {
helpers.formatResponse.entries.calledOnce.should.be.true();
renderer.renderer.callsFake(function () {
renderer.formatResponse.entries.calledOnce.should.be.true();
tagsReadStub.called.should.be.false();
helpers.secure.called.should.be.false();
renderer.secure.called.should.be.false();
done();
});
@ -109,10 +109,10 @@ describe('Unit - services/routing/controllers/static', function () {
tagsReadStub = sinon.stub().resolves({tags: [{slug: 'bacon'}]});
helpers.renderer.callsFake(function () {
renderer.renderer.callsFake(function () {
tagsReadStub.called.should.be.true();
helpers.formatResponse.entries.calledOnce.should.be.true();
helpers.secure.calledOnce.should.be.true();
renderer.formatResponse.entries.calledOnce.should.be.true();
renderer.secure.calledOnce.should.be.true();
done();
});