mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-20 17:32:15 +03:00
0b333765d4
- shutdown removed listeners, which should really be done before adding them anyway! - reset sets the cache back to an empty object, which was already done by init - merge these into one reset function that fully resets the cache - all instances of shutdown were called before an init call, and now called during init, therefore these can be removed - acceptance utils had an instance of calling shutdown and reset together as part of stopping Ghost, reworked that to be clearer
65 lines
2.2 KiB
JavaScript
65 lines
2.2 KiB
JavaScript
// Utility Packages
|
|
const path = require('path');
|
|
|
|
// Ghost Internals
|
|
const models = require('../../core/server/models');
|
|
const routingService = require('../../core/frontend/services/routing');
|
|
const settingsService = require('../../core/server/services/settings');
|
|
const settingsCache = require('../../core/server/services/settings/cache');
|
|
const imageLib = require('../../core/server/lib/image');
|
|
const themeService = require('../../core/server/services/themes');
|
|
|
|
// Other Test Utilities
|
|
const configUtils = require('./configUtils');
|
|
const urlServiceUtils = require('./url-service-utils');
|
|
|
|
module.exports = {
|
|
overrideGhostConfig: (utils) => {
|
|
utils.set('paths:contentPath', path.join(__dirname, 'fixtures'));
|
|
utils.set('times:getImageSizeTimeoutInMS', 1);
|
|
},
|
|
|
|
defaultMocks: (sandbox, options) => {
|
|
options = options || {};
|
|
|
|
configUtils.set('paths:contentPath', path.join(__dirname, 'fixtures'));
|
|
|
|
const cacheStub = sandbox.stub(settingsCache, 'get');
|
|
|
|
cacheStub.withArgs('active_theme').returns(options.theme || 'casper');
|
|
cacheStub.withArgs('timezone').returns('Etc/UTC');
|
|
cacheStub.withArgs('permalinks').returns('/:slug/');
|
|
cacheStub.withArgs('ghost_private_key').returns('-----BEGIN RSA PRIVATE KEY-----\nMB8CAQACAgPBAgMBAAECAgMFAgEfAgEfAgEXAgEXAgEA\n-----END RSA PRIVATE KEY-----\n');
|
|
cacheStub.withArgs('ghost_public_key').returns('-----BEGIN RSA PUBLIC KEY-----\nMAkCAgPBAgMBAAE=\n-----END RSA PUBLIC KEY-----\n');
|
|
|
|
if (options.amp) {
|
|
cacheStub.withArgs('amp').returns(true);
|
|
}
|
|
|
|
sandbox.stub(imageLib.imageSize, 'getImageSizeFromUrl').resolves();
|
|
},
|
|
|
|
initGhost: () => {
|
|
models.init();
|
|
|
|
return settingsService.init()
|
|
.then(() => {
|
|
return themeService.init();
|
|
});
|
|
},
|
|
|
|
routing: {
|
|
reset: function () {
|
|
routingService.registry.resetAll();
|
|
}
|
|
},
|
|
|
|
// Temporary function just for test/regression/site/site_spec.js
|
|
async urlServiceInitAndWait() {
|
|
urlServiceUtils.init();
|
|
return await urlServiceUtils.isFinished();
|
|
},
|
|
|
|
urlService: urlServiceUtils
|
|
};
|