From 8bd916929856f78bf90aa9a96fd8f88b35b9192f Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Wed, 6 Apr 2022 11:53:04 +0100 Subject: [PATCH] Removed res.locals.apiVersion - we are getting rid of the concept of having multiple api versions in a single ghost install - we no longer need to pass the apiVersion around using res.locals - To simplify code that uses our frontend proxy the proxy now _only_ exposes canary --- core/frontend/helpers/get.js | 6 +- core/frontend/helpers/prev_post.js | 3 +- core/frontend/services/data/entry-lookup.js | 2 +- core/frontend/services/data/fetch-data.js | 2 +- core/frontend/services/proxy.js | 2 +- .../routing/controllers/email-post.js | 6 +- .../services/routing/controllers/preview.js | 6 +- .../services/routing/controllers/static.js | 2 +- .../update-global-template-options.js | 2 +- core/server/api/canary/index.js | 4 +- .../web/parent/middleware/ghost-locals.js | 2 - test/e2e-frontend/helpers/get.test.js | 27 +++--- test/e2e-frontend/helpers/next_post.test.js | 89 ++++++++----------- test/unit/frontend/helpers/get.test.js | 21 ++--- test/unit/frontend/helpers/next_post.test.js | 18 +--- test/unit/frontend/helpers/prev_post.test.js | 19 ++-- .../services/data/entry-lookup.test.js | 4 +- .../frontend/services/data/fetch-data.test.js | 2 +- .../routing/controllers/preview.test.js | 4 +- .../routing/controllers/static.test.js | 4 +- .../parent/middleware/ghost-locals.test.js | 2 - 21 files changed, 86 insertions(+), 141 deletions(-) diff --git a/core/frontend/helpers/get.js b/core/frontend/helpers/get.js index 80b039e144..6de324279c 100644 --- a/core/frontend/helpers/get.js +++ b/core/frontend/helpers/get.js @@ -134,7 +134,7 @@ module.exports = function get(resource, options) { const start = Date.now(); const data = createFrame(options.data); const ghostGlobals = _.omit(data, ['_parent', 'root']); - const apiVersion = _.get(data, 'root._locals.apiVersion'); + let apiOptions = options.hash; let returnedRowsCount; @@ -151,7 +151,7 @@ module.exports = function get(resource, options) { } const controllerName = RESOURCES[resource].alias; - const controller = api[apiVersion][controllerName]; + const controller = api[controllerName]; const action = isBrowse(apiOptions) ? 'browse' : 'read'; // Parse the options we're going to pass to the API @@ -194,7 +194,7 @@ module.exports = function get(resource, options) { message: `{{#get}} helper took ${totalMs}ms to complete`, code: 'SLOW_GET_HELPER', errorDetails: { - api: `${apiVersion}.${controllerName}.${action}`, + api: `${controllerName}.${action}`, apiOptions, returnedRows: returnedRowsCount } diff --git a/core/frontend/helpers/prev_post.js b/core/frontend/helpers/prev_post.js index 981072b388..a8170fb1ca 100644 --- a/core/frontend/helpers/prev_post.js +++ b/core/frontend/helpers/prev_post.js @@ -58,10 +58,9 @@ const buildApiOptions = function buildApiOptions(options, post) { const fetch = function fetch(options, data) { const self = this; const apiOptions = buildApiOptions(options, this); - const apiVersion = data.root._locals.apiVersion; // @TODO: https://github.com/TryGhost/Ghost/issues/10548 - const controller = api[apiVersion].postsPublic || api[apiVersion].posts; + const controller = api.postsPublic || api.posts; return controller .browse(apiOptions) diff --git a/core/frontend/services/data/entry-lookup.js b/core/frontend/services/data/entry-lookup.js index 75dcf47da2..c250830ba9 100644 --- a/core/frontend/services/data/entry-lookup.js +++ b/core/frontend/services/data/entry-lookup.js @@ -14,7 +14,7 @@ const routeMatch = require('path-match')(); function entryLookup(postUrl, routerOptions, locals) { debug(postUrl); - const api = require('../proxy').api[locals.apiVersion]; + const api = require('../proxy').api; const targetPath = url.parse(postUrl).path; const permalinks = routerOptions.permalinks; let isEditURL = false; diff --git a/core/frontend/services/data/fetch-data.js b/core/frontend/services/data/fetch-data.js index 4f662376e0..409c60143f 100644 --- a/core/frontend/services/data/fetch-data.js +++ b/core/frontend/services/data/fetch-data.js @@ -45,7 +45,7 @@ defaultPostQuery.options = defaultQueryOptions.options; * @returns {Promise} */ function processQuery(query, slugParam, locals) { - const api = require('../proxy').api[locals.apiVersion]; + const api = require('../proxy').api; query = _.cloneDeep(query); diff --git a/core/frontend/services/proxy.js b/core/frontend/services/proxy.js index 929b8a05b5..96da469a75 100644 --- a/core/frontend/services/proxy.js +++ b/core/frontend/services/proxy.js @@ -39,7 +39,7 @@ module.exports = { settingsCache: settingsCache, // TODO: Expose less of the API to make this safe - api: require('../../server/api'), + api: require('../../server/api').canary, // Labs utils for enabling/disabling helpers labs: require('../../shared/labs'), diff --git a/core/frontend/services/routing/controllers/email-post.js b/core/frontend/services/routing/controllers/email-post.js index 2f4caa03d3..a882ffcb3f 100644 --- a/core/frontend/services/routing/controllers/email-post.js +++ b/core/frontend/services/routing/controllers/email-post.js @@ -14,7 +14,7 @@ const renderer = require('../../rendering'); module.exports = function emailPostController(req, res, next) { debug('emailPostController'); - const api = require('../../proxy').api[res.locals.apiVersion]; + const api = require('../../proxy').api; const params = { uuid: req.params.uuid, @@ -51,9 +51,7 @@ module.exports = function emailPostController(req, res, next) { return urlUtils.redirect301(res, routerManager.getUrlByResourceId(post.id, {withSubdirectory: true})); } - if (res.locals.apiVersion !== 'v0.1' && res.locals.apiVersion !== 'v2') { - post.access = !!post.html; - } + post.access = !!post.html; // @TODO: See renderer/secure renderer.secure(req, post); diff --git a/core/frontend/services/routing/controllers/preview.js b/core/frontend/services/routing/controllers/preview.js index 3b90bc13f7..83947da187 100644 --- a/core/frontend/services/routing/controllers/preview.js +++ b/core/frontend/services/routing/controllers/preview.js @@ -14,7 +14,7 @@ const renderer = require('../../rendering'); module.exports = function previewController(req, res, next) { debug('previewController'); - const api = require('../../proxy').api[res.locals.apiVersion]; + const api = require('../../proxy').api; const params = { uuid: req.params.uuid, @@ -53,9 +53,7 @@ module.exports = function previewController(req, res, next) { return urlUtils.redirect301(res, routerManager.getUrlByResourceId(post.id, {withSubdirectory: true})); } - if (res.locals.apiVersion !== 'v0.1' && res.locals.apiVersion !== 'v2') { - post.access = !!post.html; - } + post.access = !!post.html; // @TODO: See renderer/secure renderer.secure(req, post); diff --git a/core/frontend/services/routing/controllers/static.js b/core/frontend/services/routing/controllers/static.js index eac1c54f44..8900f3c277 100644 --- a/core/frontend/services/routing/controllers/static.js +++ b/core/frontend/services/routing/controllers/static.js @@ -4,7 +4,7 @@ const debug = require('@tryghost/debug')('services:routing:controllers:static'); const renderer = require('../../rendering'); function processQuery(query, locals) { - const api = require('../../proxy').api[locals.apiVersion]; + const api = require('../../proxy').api; query = _.cloneDeep(query); // CASE: If you define a single data key for a static route (e.g. data: page.team), this static route will represent diff --git a/core/frontend/services/theme-engine/middleware/update-global-template-options.js b/core/frontend/services/theme-engine/middleware/update-global-template-options.js index f4b906635c..5589986cd5 100644 --- a/core/frontend/services/theme-engine/middleware/update-global-template-options.js +++ b/core/frontend/services/theme-engine/middleware/update-global-template-options.js @@ -47,7 +47,7 @@ function calculateLegacyPriceData(products) { async function getProductAndPricesData() { try { - const page = await api.canary.productsPublic.browse({ + const page = await api.productsPublic.browse({ include: ['monthly_price', 'yearly_price', 'benefits'], limit: 'all', filter: 'active:true' diff --git a/core/server/api/canary/index.js b/core/server/api/canary/index.js index 90bb200838..2503d383f0 100644 --- a/core/server/api/canary/index.js +++ b/core/server/api/canary/index.js @@ -190,8 +190,8 @@ module.exports = { * * @NOTE: * - * Please create separate controllers for Content & Admin API. The goal is to expose `api.canary.content` and - * `api.canary.admin` soon. Need to figure out how serializers & validation works then. + * Please create separate controllers for Content & Admin API. The goal is to expose `api.content` and + * `api.admin` soon. Need to figure out how serializers & validation works then. */ get pagesPublic() { return shared.pipeline(require('./pages-public'), localUtils, 'content'); diff --git a/core/server/web/parent/middleware/ghost-locals.js b/core/server/web/parent/middleware/ghost-locals.js index e860cfa0a5..213abedba7 100644 --- a/core/server/web/parent/middleware/ghost-locals.js +++ b/core/server/web/parent/middleware/ghost-locals.js @@ -11,8 +11,6 @@ module.exports = function ghostLocals(req, res, next) { res.locals.safeVersion = ghostVersion.safe; // relative path from the URL res.locals.relativeUrl = req.path; - // @TODO: remove - res.locals.apiVersion = 'canary'; next(); }; diff --git a/test/e2e-frontend/helpers/get.test.js b/test/e2e-frontend/helpers/get.test.js index 878fa673e1..a0c8380f00 100644 --- a/test/e2e-frontend/helpers/get.test.js +++ b/test/e2e-frontend/helpers/get.test.js @@ -3,7 +3,6 @@ const sinon = require('sinon'); const testUtils = require('../../utils'); const models = require('../../../core/server/models/index'); -const API_VERSION = 'canary'; const DEFAULT_POST_FIXTURE_COUNT = 7; const get = require('../../../core/frontend/helpers/get'); @@ -31,7 +30,7 @@ function buildMember(status, products = []) { function testPosts(posts, map) { posts.should.be.an.Array(); posts.length.should.eql(DEFAULT_POST_FIXTURE_COUNT + Object.keys(map).length); - + // Free post for (const postID in map) { const expectData = map[postID]; @@ -94,7 +93,7 @@ describe('e2e {{#get}} helper', function () { beforeEach(function () { fn = sinon.spy(); inverse = sinon.spy(); - locals = {root: {_locals: {apiVersion: API_VERSION}}}; + locals = {root: {_locals: {}}}; }); describe('{{access}} property', function () { @@ -102,7 +101,7 @@ describe('e2e {{#get}} helper', function () { it('not authenticated member', async function () { member = null; - locals = {root: {_locals: {apiVersion: API_VERSION}}, member}; + locals = {root: {_locals: {}}, member}; await get.call( {}, 'posts', @@ -126,7 +125,7 @@ describe('e2e {{#get}} helper', function () { it('free member', async function () { member = buildMember('free'); - locals = {root: {_locals: {apiVersion: API_VERSION}}, member}; + locals = {root: {_locals: {}}, member}; await get.call( {}, 'posts', @@ -150,7 +149,7 @@ describe('e2e {{#get}} helper', function () { it('paid member', async function () { member = buildMember('paid'); - locals = {root: {_locals: {apiVersion: API_VERSION}}, member}; + locals = {root: {_locals: {}}, member}; await get.call( {}, 'posts', @@ -174,7 +173,7 @@ describe('e2e {{#get}} helper', function () { it('comped member', async function () { member = buildMember('comped'); - locals = {root: {_locals: {apiVersion: API_VERSION}}, member}; + locals = {root: {_locals: {}}, member}; await get.call( {}, 'posts', @@ -206,8 +205,8 @@ describe('e2e {{#get}} helper', function () { type: 'paid', active: true }]); - - locals = {root: {_locals: {apiVersion: API_VERSION}}, member}; + + locals = {root: {_locals: {}}, member}; await get.call( {}, 'posts', @@ -236,8 +235,8 @@ describe('e2e {{#get}} helper', function () { type: 'paid', active: true }]); - - locals = {root: {_locals: {apiVersion: API_VERSION}}, member}; + + locals = {root: {_locals: {}}, member}; await get.call( {}, 'posts', @@ -266,8 +265,8 @@ describe('e2e {{#get}} helper', function () { type: 'paid', active: true }]); - - locals = {root: {_locals: {apiVersion: API_VERSION}}, member}; + + locals = {root: {_locals: {}}, member}; await get.call( {}, 'posts', @@ -289,4 +288,4 @@ describe('e2e {{#get}} helper', function () { }); }); }); -}); \ No newline at end of file +}); diff --git a/test/e2e-frontend/helpers/next_post.test.js b/test/e2e-frontend/helpers/next_post.test.js index 43c07f3c7d..44f40a4ded 100644 --- a/test/e2e-frontend/helpers/next_post.test.js +++ b/test/e2e-frontend/helpers/next_post.test.js @@ -3,8 +3,6 @@ const sinon = require('sinon'); const testUtils = require('../../utils'); const models = require('../../../core/server/models/index'); -const API_VERSION = 'canary'; - const next_post = require('../../../core/frontend/helpers/prev_post'); async function createPost(data) { @@ -91,15 +89,12 @@ describe('e2e {{#next_post}} helper', function () { const member = null; const locals = { root: { - _locals: { - apiVersion: API_VERSION - }, context: ['post'] }, member }; let optionsData; - + beforeEach(function () { optionsData = {name: 'next_post', data: locals, fn, inverse}; }); @@ -107,28 +102,28 @@ describe('e2e {{#next_post}} helper', function () { it('next members post', async function () { await next_post .call(publicPost, optionsData); - + fn.firstCall.args[0].should.match({id: membersPost.id, access: false}); }); - + it('next paid post', async function () { await next_post .call(membersPost, optionsData); - + fn.firstCall.args[0].should.match({id: paidPost.id, access: false}); }); - + it('next tiers post', async function () { await next_post .call(paidPost, optionsData); - + fn.firstCall.args[0].should.match({id: basicTierPost.id, access: false}); }); it('next public post', async function () { await next_post .call(basicTierPost, optionsData); - + fn.firstCall.args[0].should.match({id: publicPost2.id, access: true}); }); }); @@ -137,15 +132,12 @@ describe('e2e {{#next_post}} helper', function () { const member = buildMember('free'); const locals = { root: { - _locals: { - apiVersion: API_VERSION - }, context: ['post'] }, member }; let optionsData; - + beforeEach(function () { optionsData = {name: 'next_post', data: locals, fn, inverse}; }); @@ -153,28 +145,28 @@ describe('e2e {{#next_post}} helper', function () { it('next members post', async function () { await next_post .call(publicPost, optionsData); - + fn.firstCall.args[0].should.match({id: membersPost.id, access: true}); }); - + it('next paid post', async function () { await next_post .call(membersPost, optionsData); - + fn.firstCall.args[0].should.match({id: paidPost.id, access: false}); }); - + it('next tiers post', async function () { await next_post .call(paidPost, optionsData); - + fn.firstCall.args[0].should.match({id: basicTierPost.id, access: false}); }); it('next public post', async function () { await next_post .call(basicTierPost, optionsData); - + fn.firstCall.args[0].should.match({id: publicPost2.id, access: true}); }); }); @@ -183,15 +175,12 @@ describe('e2e {{#next_post}} helper', function () { const member = buildMember('paid'); const locals = { root: { - _locals: { - apiVersion: API_VERSION - }, context: ['post'] }, member }; let optionsData; - + beforeEach(function () { optionsData = {name: 'next_post', data: locals, fn, inverse}; }); @@ -199,28 +188,28 @@ describe('e2e {{#next_post}} helper', function () { it('next members post', async function () { await next_post .call(publicPost, optionsData); - + fn.firstCall.args[0].should.match({id: membersPost.id, access: true}); }); - + it('next paid post', async function () { await next_post .call(membersPost, optionsData); - + fn.firstCall.args[0].should.match({id: paidPost.id, access: true}); }); - + it('next tiers post', async function () { await next_post .call(paidPost, optionsData); - + fn.firstCall.args[0].should.match({id: basicTierPost.id, access: false}); }); it('next public post', async function () { await next_post .call(basicTierPost, optionsData); - + fn.firstCall.args[0].should.match({id: publicPost2.id, access: true}); }); }); @@ -235,15 +224,12 @@ describe('e2e {{#next_post}} helper', function () { const locals = { root: { - _locals: { - apiVersion: API_VERSION - }, context: ['post'] }, member }; let optionsData; - + beforeEach(function () { optionsData = {name: 'next_post', data: locals, fn, inverse}; }); @@ -251,28 +237,28 @@ describe('e2e {{#next_post}} helper', function () { it('next members post', async function () { await next_post .call(publicPost, optionsData); - + fn.firstCall.args[0].should.match({id: membersPost.id, access: true}); }); - + it('next paid post', async function () { await next_post .call(membersPost, optionsData); - + fn.firstCall.args[0].should.match({id: paidPost.id, access: true}); }); - + it('next tiers post', async function () { await next_post .call(paidPost, optionsData); - + fn.firstCall.args[0].should.match({id: basicTierPost.id, access: true}); }); it('next public post', async function () { await next_post .call(basicTierPost, optionsData); - + fn.firstCall.args[0].should.match({id: publicPost2.id, access: true}); }); }); @@ -287,15 +273,12 @@ describe('e2e {{#next_post}} helper', function () { const locals = { root: { - _locals: { - apiVersion: API_VERSION - }, context: ['post'] }, member }; let optionsData; - + beforeEach(function () { optionsData = {name: 'next_post', data: locals, fn, inverse}; }); @@ -303,30 +286,30 @@ describe('e2e {{#next_post}} helper', function () { it('next members post', async function () { await next_post .call(publicPost, optionsData); - + fn.firstCall.args[0].should.match({id: membersPost.id, access: true}); }); - + it('next paid post', async function () { await next_post .call(membersPost, optionsData); - + fn.firstCall.args[0].should.match({id: paidPost.id, access: true}); }); - + it('next tiers post', async function () { await next_post .call(paidPost, optionsData); - + fn.firstCall.args[0].should.match({id: basicTierPost.id, access: false}); }); it('next public post', async function () { await next_post .call(basicTierPost, optionsData); - + fn.firstCall.args[0].should.match({id: publicPost2.id, access: true}); }); }); }); -}); \ No newline at end of file +}); diff --git a/test/unit/frontend/helpers/get.test.js b/test/unit/frontend/helpers/get.test.js index 1f97b1f8e4..39650e26c0 100644 --- a/test/unit/frontend/helpers/get.test.js +++ b/test/unit/frontend/helpers/get.test.js @@ -5,14 +5,9 @@ const {SafeString} = require('../../../../core/frontend/services/handlebars'); // Stuff we are testing const get = require('../../../../core/frontend/helpers/get'); - const models = require('../../../../core/server/models'); - const proxy = require('../../../../core/frontend/services/proxy'); - -const API_VERSION = 'canary'; - -const api = require('../../../../core/server/api')[API_VERSION]; +const api = require('../../../../core/server/api').canary; describe('{{#get}} helper', function () { let fn; @@ -27,7 +22,7 @@ describe('{{#get}} helper', function () { fn = sinon.spy(); inverse = sinon.spy(); - locals = {root: {_locals: {apiVersion: API_VERSION}}, globalProp: {foo: 'bar'}}; + locals = {root: {}, globalProp: {foo: 'bar'}}; }); afterEach(function () { @@ -39,7 +34,7 @@ describe('{{#get}} helper', function () { const meta = {pagination: {}}; beforeEach(function () { - locals = {root: {_locals: {apiVersion: 'canary'}}}; + locals = {root: {_locals: {}}}; browsePostsStub = sinon.stub(api, 'postsPublic').get(() => { return { @@ -64,12 +59,12 @@ describe('{{#get}} helper', function () { }); }); - describe('authors canary', function () { + describe('authors', function () { let browseAuthorsStub; const meta = {pagination: {}}; beforeEach(function () { - locals = {root: {_locals: {apiVersion: API_VERSION}}}; + locals = {root: {_locals: {}}}; browseAuthorsStub = sinon.stub(api, 'authorsPublic').get(() => { return { @@ -274,7 +269,7 @@ describe('{{#get}} helper', function () { }); it('Behaves normally without config', async function () { - locals = {root: {_locals: {apiVersion: API_VERSION}}}; + locals = {root: {_locals: {}}}; await get.call( {}, 'posts', @@ -286,7 +281,7 @@ describe('{{#get}} helper', function () { it('Replaces "all" with "getHelperLimitAllMax" config, if present', async function () { sinon.stub(proxy.config, 'get').withArgs('getHelperLimitAllMax').returns(2); - locals = {root: {_locals: {apiVersion: API_VERSION}}}; + locals = {root: {_locals: {}}}; await get.call( {}, 'posts', @@ -315,7 +310,7 @@ describe('{{#get}} helper', function () { }); it('should pass the member context', async function () { - locals = {root: {_locals: {apiVersion: API_VERSION}}, member}; + locals = {root: {_locals: {}}, member}; await get.call( {}, 'posts', diff --git a/test/unit/frontend/helpers/next_post.test.js b/test/unit/frontend/helpers/next_post.test.js index a1d4f2dae8..b87c74acdc 100644 --- a/test/unit/frontend/helpers/next_post.test.js +++ b/test/unit/frontend/helpers/next_post.test.js @@ -7,16 +7,13 @@ const api = require('../../../../core/server/api'); const should = require('should'); describe('{{next_post}} helper', function () { - const apiVersion = 'canary'; let locals; let browsePostsStub; beforeEach(function () { locals = { root: { - _locals: { - apiVersion: apiVersion - }, + _locals: {}, context: ['post'] } }; @@ -130,9 +127,7 @@ describe('{{next_post}} helper', function () { beforeEach(function () { locals = { root: { - _locals: { - apiVersion: apiVersion - }, + _locals: {}, context: ['page'] } }; @@ -169,9 +164,6 @@ describe('{{next_post}} helper', function () { beforeEach(function () { locals = { root: { - _locals: { - apiVersion: apiVersion - }, context: ['preview', 'post'] } }; @@ -413,9 +405,7 @@ describe('{{next_post}} helper', function () { }); locals = { root: { - _locals: { - apiVersion: apiVersion - }, + _locals: {}, context: ['post'] }, member @@ -446,7 +436,7 @@ describe('{{next_post}} helper', function () { fn.firstCall.args[1].should.be.an.Object().and.have.property('data'); browsePostsStub.calledOnce.should.be.true(); browsePostsStub.firstCall.args[0].include.should.eql('author,authors,tags,tiers'); - + // Check context passed browsePostsStub.firstCall.args[0].context.member.should.eql(member); }); diff --git a/test/unit/frontend/helpers/prev_post.test.js b/test/unit/frontend/helpers/prev_post.test.js index bc8f666a48..900a91f315 100644 --- a/test/unit/frontend/helpers/prev_post.test.js +++ b/test/unit/frontend/helpers/prev_post.test.js @@ -7,16 +7,13 @@ const api = require('../../../../core/server/api'); const should = require('should'); describe('{{prev_post}} helper', function () { - const apiVersion = 'canary'; let browsePostsStub; let locals; beforeEach(function () { locals = { root: { - _locals: { - apiVersion: apiVersion - }, + _locals: {}, context: ['post'] } }; @@ -131,9 +128,7 @@ describe('{{prev_post}} helper', function () { beforeEach(function () { locals = { root: { - _locals: { - apiVersion: apiVersion - }, + _locals: {}, context: ['page'] } }; @@ -171,9 +166,7 @@ describe('{{prev_post}} helper', function () { beforeEach(function () { locals = { root: { - _locals: { - apiVersion: apiVersion - }, + _locals: {}, context: ['preview', 'post'] } }; @@ -416,9 +409,7 @@ describe('{{prev_post}} helper', function () { }); locals = { root: { - _locals: { - apiVersion: apiVersion - }, + _locals: {}, context: ['post'] }, member @@ -449,7 +440,7 @@ describe('{{prev_post}} helper', function () { fn.firstCall.args[1].should.be.an.Object().and.have.property('data'); browsePostsStub.calledOnce.should.be.true(); browsePostsStub.firstCall.args[0].include.should.eql('author,authors,tags,tiers'); - + // Check context passed browsePostsStub.firstCall.args[0].context.member.should.eql(member); }); diff --git a/test/unit/frontend/services/data/entry-lookup.test.js b/test/unit/frontend/services/data/entry-lookup.test.js index 72a6b22213..22bef150c2 100644 --- a/test/unit/frontend/services/data/entry-lookup.test.js +++ b/test/unit/frontend/services/data/entry-lookup.test.js @@ -48,7 +48,7 @@ describe('Unit - frontend/data/entry-lookup', function () { }; }); - locals = {apiVersion: API_VERSION}; + locals = {}; }); it('ensure pages controller is triggered', function () { @@ -99,7 +99,7 @@ describe('Unit - frontend/data/entry-lookup', function () { }; }); - locals = {apiVersion: API_VERSION}; + locals = {}; }); it('ensure posts controller is triggered', function () { diff --git a/test/unit/frontend/services/data/fetch-data.test.js b/test/unit/frontend/services/data/fetch-data.test.js index 5626c05a03..0a31978eb0 100644 --- a/test/unit/frontend/services/data/fetch-data.test.js +++ b/test/unit/frontend/services/data/fetch-data.test.js @@ -49,7 +49,7 @@ describe('Unit - frontend/data/fetch-data', function () { }; }); - locals = {apiVersion: API_VERSION}; + locals = {}; }); afterEach(function () { diff --git a/test/unit/frontend/services/routing/controllers/preview.test.js b/test/unit/frontend/services/routing/controllers/preview.test.js index 7a935a02d9..e7956181c2 100644 --- a/test/unit/frontend/services/routing/controllers/preview.test.js +++ b/test/unit/frontend/services/routing/controllers/preview.test.js @@ -50,9 +50,7 @@ describe('Unit - services/routing/controllers/preview', function () { routerOptions: { query: {controller: 'preview', resource: 'preview'} }, - locals: { - apiVersion: 'canary' - }, + locals: {}, render: sinon.spy(), redirect: sinon.spy(), set: sinon.spy() diff --git a/test/unit/frontend/services/routing/controllers/static.test.js b/test/unit/frontend/services/routing/controllers/static.test.js index d594ed6e24..f3aaa06d9d 100644 --- a/test/unit/frontend/services/routing/controllers/static.test.js +++ b/test/unit/frontend/services/routing/controllers/static.test.js @@ -74,9 +74,7 @@ describe('Unit - services/routing/controllers/static', function () { routerOptions: {}, render: sinon.spy(), redirect: sinon.spy(), - locals: { - apiVersion: API_VERSION - } + locals: {} }; }); diff --git a/test/unit/server/web/parent/middleware/ghost-locals.test.js b/test/unit/server/web/parent/middleware/ghost-locals.test.js index 586ba85dc1..137b52db43 100644 --- a/test/unit/server/web/parent/middleware/ghost-locals.test.js +++ b/test/unit/server/web/parent/middleware/ghost-locals.test.js @@ -26,9 +26,7 @@ describe('Theme Handler', function () { res.locals.should.be.an.Object(); should.exist(res.locals.version); should.exist(res.locals.safeVersion); - should.exist(res.locals.apiVersion); res.locals.relativeUrl.should.equal(req.path); - res.locals.apiVersion.should.equal('canary'); next.called.should.be.true(); }); });