mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-24 06:35:49 +03:00
Made content import run inline by default in test environment
refs: https://github.com/TryGhost/Toolbox/issues/431
This commit is contained in:
parent
3e13918e57
commit
56a6b5702a
@ -71,8 +71,8 @@ module.exports = {
|
||||
|
||||
importContent: {
|
||||
statusCode(result) {
|
||||
if (result && (result.data || result.images)) {
|
||||
return 201;
|
||||
if (result && (result.db || result.problems)) {
|
||||
return 200;
|
||||
} else {
|
||||
return 202;
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ const path = require('path');
|
||||
const os = require('os');
|
||||
const glob = require('glob');
|
||||
const uuid = require('uuid');
|
||||
const config = require('../../../shared/config');
|
||||
const {extract} = require('@tryghost/zip');
|
||||
const tpl = require('@tryghost/tpl');
|
||||
const logging = require('@tryghost/logging');
|
||||
@ -401,7 +402,8 @@ class ImportManager {
|
||||
* @returns {Promise<Object.<string, ImportResult>>}
|
||||
*/
|
||||
async importFromFile(file, importOptions = {}) {
|
||||
if (!importOptions.forceInline && !importOptions.runningInJob) {
|
||||
const env = config.get('env');
|
||||
if (!env?.startsWith('testing') && !importOptions.runningInJob) {
|
||||
return jobManager.addJob({
|
||||
job: () => this.importFromFile(file, Object.assign({}, importOptions, {
|
||||
runningInJob: true
|
||||
@ -434,7 +436,7 @@ class ImportManager {
|
||||
// Step 5: Cleanup any files
|
||||
await this.cleanUp();
|
||||
|
||||
if (!importOptions.forceInline) {
|
||||
if (!env?.startsWith('testing')) {
|
||||
// Step 6: Send email
|
||||
const email = this.generateCompletionEmail(importResult?.data, {
|
||||
emailRecipient: importOptions.user.email,
|
||||
@ -454,7 +456,6 @@ class ImportManager {
|
||||
|
||||
/**
|
||||
* @typedef {object} ImportOptions
|
||||
* @property {boolean} [forceInline]
|
||||
* @property {boolean} [runningInJob]
|
||||
* @property {boolean} [returnImportedData]
|
||||
* @property {boolean} [importPersistUser]
|
||||
|
@ -57,6 +57,9 @@ DataImporter = {
|
||||
name: importOptions.importTag,
|
||||
slug: slugify(importOptions.importTag)
|
||||
});
|
||||
if (!('posts_tags' in importData.data)) {
|
||||
importData.data.posts_tags = [];
|
||||
}
|
||||
for (const post of importData.data.posts || []) {
|
||||
if (!('id' in post)) {
|
||||
// Make sure post has an id if it doesn't already
|
||||
|
Loading…
Reference in New Issue
Block a user