Removed "ghost = testUtils.startGhost" pattern

refs https://github.com/TryGhost/Toolbox/issues/138

- Having the "ghost" alias only added cognitive load when reading through the test code and didn't provide any additional value. Removed the pattern to keep things simpler and more explicit
This commit is contained in:
Naz 2021-11-24 12:39:00 +04:00 committed by naz
parent e715c5b82d
commit 8dd33c5034
60 changed files with 103 additions and 187 deletions

View File

@ -9,7 +9,6 @@ const settingsCache = require('../../../../../core/shared/settings-cache');
const config = require('../../../../../core/shared/config/index');
const mailService = require('../../../../../core/server/services/mail/index');
let ghost = testUtils.startGhost;
let request;
describe('Authentication API v3', function () {
@ -17,7 +16,7 @@ describe('Authentication API v3', function () {
describe('Blog setup', function () {
before(function () {
return ghost({forceStart: true})
return testUtils.startGhost({forceStart: true})
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('url'));
@ -139,7 +138,7 @@ describe('Authentication API v3', function () {
describe('Invitation', function () {
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('url'));
@ -235,7 +234,7 @@ describe('Authentication API v3', function () {
const user = testUtils.DataGenerator.forModel.users[0];
before(function () {
return ghost({forceStart: true})
return testUtils.startGhost({forceStart: true})
.then(() => {
request = supertest.agent(config.get('url'));
})
@ -401,7 +400,7 @@ describe('Authentication API v3', function () {
describe('Reset all passwords', function () {
let sendEmail;
before(function () {
return ghost({forceStart: true})
return testUtils.startGhost({forceStart: true})
.then(() => {
request = supertest.agent(config.get('url'));
})

View File

@ -11,7 +11,6 @@ const events = require('../../../../../core/server/lib/common/events');
const testUtils = require('../../../../utils');
const localUtils = require('./utils');
let ghost = testUtils.startGhost;
let request;
let eventsTriggered;
@ -20,7 +19,7 @@ describe('DB API (canary)', function () {
let schedulerKey;
before(function () {
return ghost()
return testUtils.startGhost()
.then(() => {
request = supertest.agent(config.get('url'));
})

View File

@ -6,8 +6,6 @@ const testUtils = require('../../../../utils');
const localUtils = require('./utils');
const config = require('../../../../../core/shared/config');
const ghost = testUtils.startGhost;
let request;
const verifyJWKS = (endpoint, token) => {
@ -35,7 +33,7 @@ const verifyJWKS = (endpoint, token) => {
describe('Identities API', function () {
describe('As Owner', function () {
before(function () {
return ghost()
return testUtils.startGhost()
.then(function () {
request = supertest.agent(config.get('url'));
})
@ -72,7 +70,7 @@ describe('Identities API', function () {
describe('As non-Owner', function () {
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
request = supertest.agent(config.get('url'));
})

View File

@ -6,14 +6,12 @@ const localUtils = require('./utils');
const testUtils = require('../../../../utils');
const config = require('../../../../../core/shared/config');
const ghost = testUtils.startGhost;
describe('Images API', function () {
const images = [];
let request;
before(function () {
return ghost()
return testUtils.startGhost()
.then(function () {
request = supertest.agent(config.get('url'));
})

View File

@ -6,8 +6,6 @@ const testUtils = require('../../../../utils');
const localUtils = require('./utils');
const config = require('../../../../../core/shared/config');
const ghost = testUtils.startGhost;
let request;
describe('Labels API', function () {
@ -16,7 +14,7 @@ describe('Labels API', function () {
});
before(function () {
return ghost()
return testUtils.startGhost()
.then(function () {
request = supertest.agent(config.get('url'));
})

View File

@ -9,8 +9,6 @@ const config = require('../../../../../core/shared/config');
const labs = require('../../../../../core/shared/labs');
const mailService = require('../../../../../core/server/services/mail');
const ghost = testUtils.startGhost;
let request;
describe('Members API (canary)', function () {
@ -23,7 +21,7 @@ describe('Members API (canary)', function () {
});
before(function () {
return ghost()
return testUtils.startGhost()
.then(function () {
request = supertest.agent(config.get('url'));
})

View File

@ -7,8 +7,6 @@ const localUtils = require('./utils');
const config = require('../../../../../core/shared/config');
const labs = require('../../../../../core/shared/labs');
const ghost = testUtils.startGhost;
let request;
describe('Members Sigin URL API', function () {
@ -22,7 +20,7 @@ describe('Members Sigin URL API', function () {
describe('As Owner', function () {
before(function () {
return ghost()
return testUtils.startGhost()
.then(function () {
request = supertest.agent(config.get('url'));
})
@ -51,7 +49,7 @@ describe('Members Sigin URL API', function () {
describe('As Admin', function () {
before(function () {
return ghost()
return testUtils.startGhost()
.then(function () {
request = supertest.agent(config.get('url'));
})
@ -88,7 +86,7 @@ describe('Members Sigin URL API', function () {
describe('As non-Owner and non-Admin', function () {
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
request = supertest.agent(config.get('url'));
})

View File

@ -3,14 +3,13 @@ const supertest = require('supertest');
const testUtils = require('../../../../utils');
const config = require('../../../../../core/shared/config');
const localUtils = require('./utils');
const ghost = testUtils.startGhost;
describe('Notifications API', function () {
describe('As Editor', function () {
let request;
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
request = supertest.agent(config.get('url'));
})
@ -70,7 +69,7 @@ describe('Notifications API', function () {
let request;
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
request = supertest.agent(config.get('url'));
})
@ -118,7 +117,7 @@ describe('Notifications API', function () {
let notification;
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
requestEditor1 = supertest.agent(config.get('url'));
requestEditor2 = supertest.agent(config.get('url'));

View File

@ -3,12 +3,11 @@ const supertest = require('supertest');
const testUtils = require('../../../../utils');
const config = require('../../../../../core/shared/config');
const localUtils = require('./utils');
const ghost = testUtils.startGhost;
let request;
describe('Pages API', function () {
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
request = supertest.agent(config.get('url'));
})

View File

@ -7,13 +7,12 @@ const testUtils = require('../../../../utils');
const config = require('../../../../../core/shared/config');
const models = require('../../../../../core/server/models');
const localUtils = require('./utils');
const ghost = testUtils.startGhost;
describe('Posts API (canary)', function () {
let request;
before(async function () {
await ghost();
await testUtils.startGhost();
request = supertest.agent(config.get('url'));
await localUtils.doAuth(request, 'users:extra', 'posts', 'emails', 'members');
});

View File

@ -9,12 +9,11 @@ const testUtils = require('../../../../utils');
const localUtils = require('./utils');
const config = require('../../../../../core/shared/config');
const ghost = testUtils.startGhost;
let request;
describe('Redirects API', function () {
const startGhost = (options) => {
return ghost(options)
return testUtils.startGhost(options)
.then(() => {
request = supertest.agent(config.get('url'));
})

View File

@ -10,8 +10,6 @@ const config = require('../../../../../core/shared/config/index');
const testUtils = require('../../../../utils/index');
const localUtils = require('./utils');
const ghost = testUtils.startGhost;
describe('Canary Schedules API', function () {
const resources = [];
let request;
@ -28,7 +26,7 @@ describe('Canary Schedules API', function () {
});
before(async function () {
await ghost();
await testUtils.startGhost();
request = supertest.agent(config.get('url'));

View File

@ -5,7 +5,6 @@ const config = require('../../../../../core/shared/config');
const testUtils = require('../../../../utils');
const localUtils = require('./utils');
const db = require('../../../../../core/server/data/db');
const ghost = testUtils.startGhost;
// NOTE: in future iterations these fields should be fetched from a central module.
// Have put a list as is here for the lack of better place for it.
@ -443,7 +442,7 @@ describe('Settings API (canary)', function () {
describe('As Owner', function () {
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('url'));
@ -1270,7 +1269,7 @@ describe('Settings API (canary)', function () {
describe('As Admin', function () {
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('url'));
@ -1295,7 +1294,7 @@ describe('Settings API (canary)', function () {
let editor;
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('url'));
@ -1356,7 +1355,7 @@ describe('Settings API (canary)', function () {
describe('As Author', function () {
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('url'));

View File

@ -5,7 +5,6 @@ const testUtils = require('../../../../utils');
const localUtils = require('./utils');
const config = require('../../../../../core/shared/config');
const events = require('../../../../../core/server/lib/common/events');
const ghost = testUtils.startGhost;
let request;
@ -13,7 +12,7 @@ describe('Slack API', function () {
let ghostServer;
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('url'));

View File

@ -4,7 +4,6 @@ const ObjectId = require('bson-objectid');
const testUtils = require('../../../../utils');
const config = require('../../../../../core/shared/config');
const localUtils = require('./utils');
const ghost = testUtils.startGhost;
let request;
describe('User API', function () {
@ -16,7 +15,7 @@ describe('User API', function () {
describe('As Owner', function () {
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('url'));
@ -149,7 +148,7 @@ describe('User API', function () {
describe('As Editor', function () {
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('url'));
@ -229,7 +228,7 @@ describe('User API', function () {
describe('As Author', function () {
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('url'));

View File

@ -4,14 +4,12 @@ const testUtils = require('../../../../utils');
const config = require('../../../../../core/shared/config');
const localUtils = require('./utils');
const ghost = testUtils.startGhost;
describe('Webhooks API (canary)', function () {
let request;
const API_VERSION = 'canary';
before(async function () {
await ghost();
await testUtils.startGhost();
request = supertest.agent(config.get('url'));

View File

@ -5,14 +5,12 @@ const testUtils = require('../../../../utils');
const configUtils = require('../../../../utils/configUtils');
const config = require('../../../../../core/shared/config');
const ghost = testUtils.startGhost;
describe('Authors Content API', function () {
const validKey = localUtils.getValidKey();
let request;
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
request = supertest.agent(config.get('url'));
})

View File

@ -5,14 +5,13 @@ const localUtils = require('./utils');
const configUtils = require('../../../../utils/configUtils');
const config = require('../../../../../core/shared/config');
const ghost = testUtils.startGhost;
let request;
describe('api/canary/content/pages', function () {
const key = localUtils.getValidKey();
before(function () {
return ghost()
return testUtils.startGhost()
.then(function () {
request = supertest.agent(config.get('url'));
})

View File

@ -10,13 +10,11 @@ const configUtils = require('../../../../utils/configUtils');
const urlUtils = require('../../../../utils/urlUtils');
const config = require('../../../../../core/shared/config');
const ghost = testUtils.startGhost;
describe('api/canary/content/posts', function () {
let request;
before(async function () {
await ghost();
await testUtils.startGhost();
request = supertest.agent(config.get('url'));
await testUtils.initFixtures('users:no-owner', 'user:inactive', 'posts', 'tags:extra', 'api_keys');
});

View File

@ -6,14 +6,13 @@ const testUtils = require('../../../../utils');
const configUtils = require('../../../../utils/configUtils');
const config = require('../../../../../core/shared/config');
const ghost = testUtils.startGhost;
let request;
describe('api/canary/content/tags', function () {
const validKey = localUtils.getValidKey();
before(function () {
return ghost()
return testUtils.startGhost()
.then(function () {
request = supertest.agent(config.get('url'));
})

View File

@ -10,7 +10,6 @@ const config = require('../../../../../core/shared/config/index');
const mailService = require('../../../../../core/server/services/mail/index');
const configUtils = require('../../../../utils/configUtils');
let ghost = testUtils.startGhost;
let request;
describe('Authentication API v2', function () {
@ -18,7 +17,7 @@ describe('Authentication API v2', function () {
describe('Blog setup: default config', function () {
before(function () {
return ghost({forceStart: true})
return testUtils.startGhost({forceStart: true})
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('url'));
@ -138,7 +137,7 @@ describe('Authentication API v2', function () {
describe('Blog setup: custom config', function () {
before(function () {
return ghost({forceStart: true})
return testUtils.startGhost({forceStart: true})
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('url'));
@ -261,7 +260,7 @@ describe('Authentication API v2', function () {
describe('Invitation', function () {
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('url'));
@ -341,7 +340,7 @@ describe('Authentication API v2', function () {
const user = testUtils.DataGenerator.forModel.users[0];
before(function () {
return ghost({forceStart: true})
return testUtils.startGhost({forceStart: true})
.then(() => {
request = supertest.agent(config.get('url'));
})

View File

@ -11,7 +11,6 @@ const events = require('../../../../../core/server/lib/common/events');
const testUtils = require('../../../../utils');
const localUtils = require('./utils');
let ghost = testUtils.startGhost;
let request;
let eventsTriggered;
@ -20,7 +19,7 @@ describe('DB API (v2)', function () {
let schedulerKey;
before(function () {
return ghost()
return testUtils.startGhost()
.then(() => {
request = supertest.agent(config.get('url'));
})

View File

@ -6,14 +6,12 @@ const localUtils = require('./utils');
const testUtils = require('../../../../utils');
const config = require('../../../../../core/shared/config');
const ghost = testUtils.startGhost;
describe('Images API', function () {
const images = [];
let request;
before(function () {
return ghost()
return testUtils.startGhost()
.then(function () {
request = supertest.agent(config.get('url'));
})

View File

@ -3,14 +3,13 @@ const supertest = require('supertest');
const testUtils = require('../../../../utils');
const config = require('../../../../../core/shared/config');
const localUtils = require('./utils');
const ghost = testUtils.startGhost;
describe('Notifications API', function () {
describe('As Editor', function () {
let request;
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
request = supertest.agent(config.get('url'));
})
@ -70,7 +69,7 @@ describe('Notifications API', function () {
let request;
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
request = supertest.agent(config.get('url'));
})
@ -118,7 +117,7 @@ describe('Notifications API', function () {
let notification;
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
requestEditor1 = supertest.agent(config.get('url'));
requestEditor2 = supertest.agent(config.get('url'));

View File

@ -9,14 +9,12 @@ const localUtils = require('./utils');
// for sinon stubs
const dnsPromises = require('dns').promises;
const ghost = testUtils.startGhost;
describe('Oembed API (v2)', function () {
let ghostServer;
let request;
before(function () {
return ghost()
return testUtils.startGhost()
.then((_ghostServer) => {
ghostServer = _ghostServer;
request = supertest.agent(config.get('url'));

View File

@ -3,12 +3,11 @@ const supertest = require('supertest');
const testUtils = require('../../../../utils');
const config = require('../../../../../core/shared/config');
const localUtils = require('./utils');
const ghost = testUtils.startGhost;
let request;
describe('Pages API', function () {
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
request = supertest.agent(config.get('url'));
})

View File

@ -6,14 +6,13 @@ const testUtils = require('../../../../utils');
const config = require('../../../../../core/shared/config');
const models = require('../../../../../core/server/models');
const localUtils = require('./utils');
const ghost = testUtils.startGhost;
describe('Posts API (v2)', function () {
let request;
let ownerCookie;
before(async function () {
await ghost();
await testUtils.startGhost();
request = supertest.agent(config.get('url'));
ownerCookie = await localUtils.doAuth(request, 'users:extra', 'posts');
});

View File

@ -9,12 +9,11 @@ const testUtils = require('../../../../utils');
const localUtils = require('./utils');
const config = require('../../../../../core/shared/config');
const ghost = testUtils.startGhost;
let request;
describe('Redirects API', function () {
const startGhost = (options) => {
return ghost(options)
return testUtils.startGhost(options)
.then(() => {
request = supertest.agent(config.get('url'));
})

View File

@ -10,8 +10,6 @@ const config = require('../../../../../core/shared/config/index');
const testUtils = require('../../../../utils/index');
const localUtils = require('./utils');
const ghost = testUtils.startGhost;
describe('v2 Schedules API', function () {
const resources = [];
let request;
@ -28,7 +26,7 @@ describe('v2 Schedules API', function () {
});
before(async function () {
await ghost();
await testUtils.startGhost();
request = supertest.agent(config.get('url'));

View File

@ -3,7 +3,6 @@ const supertest = require('supertest');
const config = require('../../../../../core/shared/config');
const testUtils = require('../../../../utils');
const localUtils = require('./utils');
const ghost = testUtils.startGhost;
// NOTE: in future iterations these fields should be fetched from a central module.
// Have put a list as is here for the lack of better place for it.
@ -97,7 +96,7 @@ describe('Settings API (v2)', function () {
describe('As Owner', function () {
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('url'));
@ -729,7 +728,7 @@ describe('Settings API (v2)', function () {
describe('As Admin', function () {
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('url'));
@ -754,7 +753,7 @@ describe('Settings API (v2)', function () {
let editor;
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('url'));
@ -815,7 +814,7 @@ describe('Settings API (v2)', function () {
describe('As Author', function () {
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('url'));

View File

@ -5,7 +5,6 @@ const testUtils = require('../../../../utils');
const localUtils = require('./utils');
const config = require('../../../../../core/shared/config');
const events = require('../../../../../core/server/lib/common/events');
const ghost = testUtils.startGhost;
let request;
@ -13,7 +12,7 @@ describe('Slack API', function () {
let ghostServer;
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('url'));

View File

@ -4,7 +4,6 @@ const ObjectId = require('bson-objectid');
const testUtils = require('../../../../utils');
const config = require('../../../../../core/shared/config');
const localUtils = require('./utils');
const ghost = testUtils.startGhost;
let request;
describe('User API', function () {
@ -16,7 +15,7 @@ describe('User API', function () {
describe('As Owner', function () {
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('url'));
@ -149,7 +148,7 @@ describe('User API', function () {
describe('As Editor', function () {
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('url'));
@ -229,7 +228,7 @@ describe('User API', function () {
describe('As Author', function () {
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('url'));

View File

@ -4,14 +4,12 @@ const testUtils = require('../../../../utils');
const config = require('../../../../../core/shared/config');
const localUtils = require('./utils');
const ghost = testUtils.startGhost;
describe('Webhooks API (v2)', function () {
let request;
const API_VERSION = 'v2';
before(async function () {
await ghost();
await testUtils.startGhost();
request = supertest.agent(config.get('url'));

View File

@ -5,14 +5,12 @@ const testUtils = require('../../../../utils');
const configUtils = require('../../../../utils/configUtils');
const config = require('../../../../../core/shared/config');
const ghost = testUtils.startGhost;
describe('Authors Content API', function () {
const validKey = localUtils.getValidKey();
let request;
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
request = supertest.agent(config.get('url'));
})

View File

@ -6,12 +6,11 @@ const localUtils = require('./utils');
const configUtils = require('../../../../utils/configUtils');
const config = require('../../../../../core/shared/config');
const ghost = testUtils.startGhost;
let request;
describe('api/v2/content/pages', function () {
before(function () {
return ghost()
return testUtils.startGhost()
.then(function () {
request = supertest.agent(config.get('url'));
})

View File

@ -12,13 +12,11 @@ const configUtils = require('../../../../utils/configUtils');
const urlUtils = require('../../../../utils/urlUtils');
const config = require('../../../../../core/shared/config');
const ghost = testUtils.startGhost;
describe('api/v2/content/posts', function () {
let request;
before(async function () {
await ghost();
await testUtils.startGhost();
request = supertest.agent(config.get('url'));
await testUtils.initFixtures('users:no-owner', 'user:inactive', 'posts', 'tags:extra', 'api_keys');
});

View File

@ -6,12 +6,11 @@ const testUtils = require('../../../../utils');
const configUtils = require('../../../../utils/configUtils');
const config = require('../../../../../core/shared/config');
const ghost = testUtils.startGhost;
let request;
describe('api/v2/content/tags', function () {
before(function () {
return ghost()
return testUtils.startGhost()
.then(function () {
request = supertest.agent(config.get('url'));
})

View File

@ -9,7 +9,6 @@ const settingsCache = require('../../../../../core/shared/settings-cache');
const config = require('../../../../../core/shared/config/index');
const mailService = require('../../../../../core/server/services/mail/index');
let ghost = testUtils.startGhost;
let request;
describe('Authentication API v3', function () {
@ -17,7 +16,7 @@ describe('Authentication API v3', function () {
describe('Blog setup', function () {
before(function () {
return ghost({forceStart: true})
return testUtils.startGhost({forceStart: true})
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('url'));
@ -138,7 +137,7 @@ describe('Authentication API v3', function () {
describe('Invitation', function () {
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('url'));
@ -234,7 +233,7 @@ describe('Authentication API v3', function () {
const user = testUtils.DataGenerator.forModel.users[0];
before(function () {
return ghost({forceStart: true})
return testUtils.startGhost({forceStart: true})
.then(() => {
request = supertest.agent(config.get('url'));
})

View File

@ -11,7 +11,6 @@ const events = require('../../../../../core/server/lib/common/events');
const testUtils = require('../../../../utils');
const localUtils = require('./utils');
let ghost = testUtils.startGhost;
let request;
let eventsTriggered;
@ -20,7 +19,7 @@ describe('DB API (v3)', function () {
let schedulerKey;
before(function () {
return ghost()
return testUtils.startGhost()
.then(() => {
request = supertest.agent(config.get('url'));
})

View File

@ -6,8 +6,6 @@ const testUtils = require('../../../../utils');
const localUtils = require('./utils');
const config = require('../../../../../core/shared/config');
const ghost = testUtils.startGhost;
let request;
const verifyJWKS = (endpoint, token) => {
@ -35,7 +33,7 @@ const verifyJWKS = (endpoint, token) => {
describe('Identities API', function () {
describe('As Owner', function () {
before(function () {
return ghost()
return testUtils.startGhost()
.then(function () {
request = supertest.agent(config.get('url'));
})
@ -72,7 +70,7 @@ describe('Identities API', function () {
describe('As non-Owner', function () {
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
request = supertest.agent(config.get('url'));
})

View File

@ -6,14 +6,12 @@ const localUtils = require('./utils');
const testUtils = require('../../../../utils');
const config = require('../../../../../core/shared/config');
const ghost = testUtils.startGhost;
describe('Images API', function () {
const images = [];
let request;
before(function () {
return ghost()
return testUtils.startGhost()
.then(function () {
request = supertest.agent(config.get('url'));
})

View File

@ -6,8 +6,6 @@ const testUtils = require('../../../../utils');
const localUtils = require('./utils');
const config = require('../../../../../core/shared/config');
const ghost = testUtils.startGhost;
let request;
describe('Labels API', function () {
@ -16,7 +14,7 @@ describe('Labels API', function () {
});
before(function () {
return ghost()
return testUtils.startGhost()
.then(function () {
request = supertest.agent(config.get('url'));
})

View File

@ -9,8 +9,6 @@ const config = require('../../../../../core/shared/config');
const labs = require('../../../../../core/shared/labs');
const mailService = require('../../../../../core/server/services/mail');
const ghost = testUtils.startGhost;
let request;
describe('Members API', function () {
@ -23,7 +21,7 @@ describe('Members API', function () {
});
before(function () {
return ghost()
return testUtils.startGhost()
.then(function () {
request = supertest.agent(config.get('url'));
})

View File

@ -7,8 +7,6 @@ const localUtils = require('./utils');
const config = require('../../../../../core/shared/config');
const labs = require('../../../../../core/shared/labs');
const ghost = testUtils.startGhost;
let request;
describe('Members Sigin URL API', function () {
@ -22,7 +20,7 @@ describe('Members Sigin URL API', function () {
describe('As Owner', function () {
before(function () {
return ghost()
return testUtils.startGhost()
.then(function () {
request = supertest.agent(config.get('url'));
})
@ -51,7 +49,7 @@ describe('Members Sigin URL API', function () {
describe('As Admin', function () {
before(function () {
return ghost()
return testUtils.startGhost()
.then(function () {
request = supertest.agent(config.get('url'));
})
@ -88,7 +86,7 @@ describe('Members Sigin URL API', function () {
describe('As non-Owner and non-Admin', function () {
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
request = supertest.agent(config.get('url'));
})

View File

@ -3,14 +3,13 @@ const supertest = require('supertest');
const testUtils = require('../../../../utils');
const config = require('../../../../../core/shared/config');
const localUtils = require('./utils');
const ghost = testUtils.startGhost;
describe('Notifications API', function () {
describe('As Editor', function () {
let request;
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
request = supertest.agent(config.get('url'));
})
@ -70,7 +69,7 @@ describe('Notifications API', function () {
let request;
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
request = supertest.agent(config.get('url'));
})
@ -118,7 +117,7 @@ describe('Notifications API', function () {
let notification;
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
requestEditor1 = supertest.agent(config.get('url'));
requestEditor2 = supertest.agent(config.get('url'));

View File

@ -3,12 +3,11 @@ const supertest = require('supertest');
const testUtils = require('../../../../utils');
const config = require('../../../../../core/shared/config');
const localUtils = require('./utils');
const ghost = testUtils.startGhost;
let request;
describe('Pages API', function () {
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
request = supertest.agent(config.get('url'));
})

View File

@ -7,14 +7,13 @@ const testUtils = require('../../../../utils');
const config = require('../../../../../core/shared/config');
const models = require('../../../../../core/server/models');
const localUtils = require('./utils');
const ghost = testUtils.startGhost;
describe('Posts API (v3)', function () {
let request;
let ownerCookie;
before(async function () {
await ghost();
await testUtils.startGhost();
request = supertest.agent(config.get('url'));
ownerCookie = await localUtils.doAuth(request, 'users:extra', 'posts', 'emails');

View File

@ -9,12 +9,11 @@ const testUtils = require('../../../../utils');
const localUtils = require('./utils');
const config = require('../../../../../core/shared/config');
const ghost = testUtils.startGhost;
let request;
describe('Redirects API', function () {
const startGhost = (options) => {
return ghost(options)
return testUtils.startGhost(options)
.then(() => {
request = supertest.agent(config.get('url'));
})

View File

@ -10,8 +10,6 @@ const config = require('../../../../../core/shared/config/index');
const testUtils = require('../../../../utils/index');
const localUtils = require('./utils');
const ghost = testUtils.startGhost;
describe('v3 Schedules API', function () {
const resources = [];
let request;
@ -28,7 +26,7 @@ describe('v3 Schedules API', function () {
});
before(async function () {
await ghost();
await testUtils.startGhost();
request = supertest.agent(config.get('url'));

View File

@ -4,7 +4,6 @@ const supertest = require('supertest');
const config = require('../../../../../core/shared/config');
const testUtils = require('../../../../utils');
const localUtils = require('./utils');
const ghost = testUtils.startGhost;
// NOTE: in future iterations these fields should be fetched from a central module.
// Have put a list as is here for the lack of better place for it.
@ -101,7 +100,7 @@ describe('Settings API (v3)', function () {
describe('As Owner', function () {
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('url'));
@ -723,7 +722,7 @@ describe('Settings API (v3)', function () {
describe('As Admin', function () {
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('url'));
@ -748,7 +747,7 @@ describe('Settings API (v3)', function () {
let editor;
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('url'));
@ -809,7 +808,7 @@ describe('Settings API (v3)', function () {
describe('As Author', function () {
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('url'));

View File

@ -5,7 +5,6 @@ const testUtils = require('../../../../utils');
const localUtils = require('./utils');
const config = require('../../../../../core/shared/config');
const events = require('../../../../../core/server/lib/common/events');
const ghost = testUtils.startGhost;
let request;
@ -13,7 +12,7 @@ describe('Slack API', function () {
let ghostServer;
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('url'));

View File

@ -4,7 +4,6 @@ const ObjectId = require('bson-objectid');
const testUtils = require('../../../../utils');
const config = require('../../../../../core/shared/config');
const localUtils = require('./utils');
const ghost = testUtils.startGhost;
let request;
describe('User API', function () {
@ -16,7 +15,7 @@ describe('User API', function () {
describe('As Owner', function () {
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('url'));
@ -149,7 +148,7 @@ describe('User API', function () {
describe('As Editor', function () {
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('url'));
@ -229,7 +228,7 @@ describe('User API', function () {
describe('As Author', function () {
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('url'));

View File

@ -4,14 +4,12 @@ const testUtils = require('../../../../utils');
const config = require('../../../../../core/shared/config');
const localUtils = require('./utils');
const ghost = testUtils.startGhost;
describe('Webhooks API (v3)', function () {
let request;
const API_VERSION = 'v3';
before(async function () {
await ghost();
await testUtils.startGhost();
request = supertest.agent(config.get('url'));

View File

@ -5,14 +5,12 @@ const testUtils = require('../../../../utils');
const configUtils = require('../../../../utils/configUtils');
const config = require('../../../../../core/shared/config');
const ghost = testUtils.startGhost;
describe('Authors Content API', function () {
const validKey = localUtils.getValidKey();
let request;
before(function () {
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
request = supertest.agent(config.get('url'));
})

View File

@ -5,14 +5,13 @@ const localUtils = require('./utils');
const configUtils = require('../../../../utils/configUtils');
const config = require('../../../../../core/shared/config');
const ghost = testUtils.startGhost;
let request;
describe('api/v3/content/pages', function () {
const key = localUtils.getValidKey();
before(function () {
return ghost()
return testUtils.startGhost()
.then(function () {
request = supertest.agent(config.get('url'));
})

View File

@ -8,13 +8,11 @@ const configUtils = require('../../../../utils/configUtils');
const urlUtils = require('../../../../utils/urlUtils');
const config = require('../../../../../core/shared/config');
const ghost = testUtils.startGhost;
describe('api/v3/content/posts', function () {
let request;
before(async function () {
await ghost();
await testUtils.startGhost();
request = supertest.agent(config.get('url'));
await testUtils.initFixtures('users:no-owner', 'user:inactive', 'posts', 'tags:extra', 'api_keys');
});

View File

@ -6,14 +6,13 @@ const testUtils = require('../../../../utils');
const configUtils = require('../../../../utils/configUtils');
const config = require('../../../../../core/shared/config');
const ghost = testUtils.startGhost;
let request;
describe('api/v3/content/tags', function () {
const validKey = localUtils.getValidKey();
before(function () {
return ghost()
return testUtils.startGhost()
.then(function () {
request = supertest.agent(config.get('url'));
})

View File

@ -14,7 +14,6 @@ const cheerio = require('cheerio');
const config = require('../../../core/shared/config');
const api = require('../../../core/server/api');
const settingsCache = require('../../../core/shared/settings-cache');
const ghost = testUtils.startGhost;
let request;
@ -47,7 +46,7 @@ describe('Dynamic Routing', function () {
return originalSettingsCacheGetFn(key, options);
});
return ghost()
return testUtils.startGhost()
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('url'));
@ -290,7 +289,7 @@ describe('Dynamic Routing', function () {
before(function () {
configUtils.set('admin:redirects', false);
return ghost({forceStart: true})
return testUtils.startGhost({forceStart: true})
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('url'));
@ -300,7 +299,7 @@ describe('Dynamic Routing', function () {
after(function () {
configUtils.restore();
return ghost({forceStart: true})
return testUtils.startGhost({forceStart: true})
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('url'));
@ -486,7 +485,7 @@ describe('Dynamic Routing', function () {
before(function () {
configUtils.set('admin:redirects', false);
return ghost({forceStart: true})
return testUtils.startGhost({forceStart: true})
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('url'));
@ -496,7 +495,7 @@ describe('Dynamic Routing', function () {
after(function () {
configUtils.restore();
return ghost({forceStart: true})
return testUtils.startGhost({forceStart: true})
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('url'));

View File

@ -11,7 +11,6 @@ const _ = require('lodash');
const testUtils = require('../../utils');
const configUtils = require('../../utils/configUtils');
const config = require('../../../core/shared/config');
const ghost = testUtils.startGhost;
let request;
describe('Frontend Routing', function () {
@ -45,7 +44,7 @@ describe('Frontend Routing', function () {
});
before(function () {
return ghost()
return testUtils.startGhost()
.then(function () {
request = supertest.agent(config.get('url'));
});
@ -185,7 +184,7 @@ describe('Frontend Routing', function () {
before(function (done) {
configUtils.set('admin:redirects', false);
ghost({forceStart: true})
testUtils.startGhost({forceStart: true})
.then(function () {
request = supertest.agent(config.get('url'));
addPosts(done);
@ -195,7 +194,7 @@ describe('Frontend Routing', function () {
after(function (done) {
configUtils.restore();
ghost({forceStart: true})
testUtils.startGhost({forceStart: true})
.then(function () {
request = supertest.agent(config.get('url'));
addPosts(done);

View File

@ -10,7 +10,6 @@ const testUtils = require('../../utils');
const configUtils = require('../../utils/configUtils');
const urlUtils = require('../../utils/urlUtils');
const config = require('../../../core/shared/config');
const ghost = testUtils.startGhost;
let request;
describe('Frontend Routing:Redirects', function () {
@ -44,7 +43,7 @@ describe('Frontend Routing:Redirects', function () {
});
before(function () {
return ghost()
return testUtils.startGhost()
.then(function () {
request = supertest.agent(config.get('url'));
});
@ -61,7 +60,7 @@ describe('Frontend Routing:Redirects', function () {
configUtils.set('url', 'http://localhost:2370/');
urlUtils.stubUrlUtilsFromConfig();
return ghost({forceStart: true, redirectsFileExt: ext})
return testUtils.startGhost({forceStart: true, redirectsFileExt: ext})
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('server:host') + ':' + config.get('server:port'));
@ -347,7 +346,7 @@ describe('Frontend Routing:Redirects', function () {
configUtils.set('url', 'http://localhost:2370/blog/');
urlUtils.stubUrlUtilsFromConfig();
return ghost({forceStart: true, subdir: true, redirectsFileExt: ext})
return testUtils.startGhost({forceStart: true, subdir: true, redirectsFileExt: ext})
.then(function (_ghostServer) {
ghostServer = _ghostServer;
request = supertest.agent(config.get('server:host') + ':' + config.get('server:port'));