diff --git a/ghost/admin/package.json b/ghost/admin/package.json index 307ac3fd96b..7d115058ec0 100644 --- a/ghost/admin/package.json +++ b/ghost/admin/package.json @@ -1,6 +1,6 @@ { "name": "ghost-admin", - "version": "6.36.1-rc.0", + "version": "6.37.0-rc.0", "description": "Ember.js admin client for Ghost", "author": "Ghost Foundation", "homepage": "http://ghost.org", diff --git a/ghost/core/core/server/api/endpoints/automated-emails.js b/ghost/core/core/server/api/endpoints/automated-emails.js index 839a2750006..94d91b1aa12 100644 --- a/ghost/core/core/server/api/endpoints/automated-emails.js +++ b/ghost/core/core/server/api/endpoints/automated-emails.js @@ -9,7 +9,7 @@ const messages = { }; // NOTE: This file is in a transitionary state. The `automated_emails` database table was split into -// `welcome_email_automations` (automation metadata: status, name, slug) and +// `automations` (automation metadata: status, name, slug) and // `welcome_email_automated_emails` (email content: subject, lexical, sender fields). This controller // acts as a facade that joins/splits data between those two models while preserving the original // `automated_emails` API shape externally. @@ -51,7 +51,7 @@ const controller = { ], permissions: true, async query(frame) { - const result = await models.WelcomeEmailAutomation.findPage({ + const result = await models.Automation.findPage({ ...frame.options, withRelated: ['welcomeEmailAutomatedEmail'] }); @@ -75,7 +75,7 @@ const controller = { ], permissions: true, async query(frame) { - const model = await models.WelcomeEmailAutomation.findOne(frame.data, { + const model = await models.Automation.findOne(frame.data, { ...frame.options, withRelated: ['welcomeEmailAutomatedEmail'] }); @@ -102,7 +102,7 @@ const controller = { const automationData = _.pick(data, AUTOMATION_FIELDS); return models.Base.transaction(async (transacting) => { - const automation = await models.WelcomeEmailAutomation.add(automationData, {...frame.options, transacting}); + const automation = await models.Automation.add(automationData, {...frame.options, transacting}); const email = await models.WelcomeEmailAutomatedEmail.add( { ...emailData, @@ -139,7 +139,7 @@ const controller = { const automationData = _.pick(data, AUTOMATION_FIELDS); return models.Base.transaction(async (transacting) => { - let automation = await models.WelcomeEmailAutomation.findOne({id: frame.options.id}, { + let automation = await models.Automation.findOne({id: frame.options.id}, { transacting, withRelated: ['welcomeEmailAutomatedEmail'] }); @@ -159,7 +159,7 @@ const controller = { } if (Object.keys(automationData).length > 0) { - automation = await models.WelcomeEmailAutomation.edit(automationData, { + automation = await models.Automation.edit(automationData, { ...frame.options, transacting }); diff --git a/ghost/core/core/server/api/endpoints/automations.js b/ghost/core/core/server/api/endpoints/automations.js index 71b56e7ca3f..da7c792340a 100644 --- a/ghost/core/core/server/api/endpoints/automations.js +++ b/ghost/core/core/server/api/endpoints/automations.js @@ -12,7 +12,7 @@ const controller = { }, permissions: true, async query() { - const automations = await models.WelcomeEmailAutomation.findAll(); + const automations = await models.Automation.findAll(); return { data: automations.map(automation => ({ id: automation.get('id'), diff --git a/ghost/core/core/server/data/exporter/table-lists.js b/ghost/core/core/server/data/exporter/table-lists.js index 1a001c0743d..065e49d4676 100644 --- a/ghost/core/core/server/data/exporter/table-lists.js +++ b/ghost/core/core/server/data/exporter/table-lists.js @@ -58,7 +58,7 @@ const BACKUP_TABLES = [ 'recommendation_subscribe_events', 'outbox', 'gifts', - 'welcome_email_automations', + 'automations', 'welcome_email_automation_runs', 'welcome_email_automated_emails' ]; diff --git a/ghost/core/core/server/data/migrations/versions/6.37/2026-05-04-13-46-58-rename-welcome-email-automations-table-to-automations.js b/ghost/core/core/server/data/migrations/versions/6.37/2026-05-04-13-46-58-rename-welcome-email-automations-table-to-automations.js new file mode 100644 index 00000000000..9bf541362f2 --- /dev/null +++ b/ghost/core/core/server/data/migrations/versions/6.37/2026-05-04-13-46-58-rename-welcome-email-automations-table-to-automations.js @@ -0,0 +1,42 @@ +const logging = require('@tryghost/logging'); +const {createNonTransactionalMigration} = require('../../utils'); + +const FROM_TABLE = 'welcome_email_automations'; +const TO_TABLE = 'automations'; + +module.exports = createNonTransactionalMigration( + async function up(connection) { + const fromExists = await connection.schema.hasTable(FROM_TABLE); + const toExists = await connection.schema.hasTable(TO_TABLE); + + if (toExists) { + logging.warn(`Skipping renaming table: ${TO_TABLE} already exists`); + return; + } + + if (!fromExists) { + logging.warn(`Skipping renaming table: ${FROM_TABLE} does not exist`); + return; + } + + logging.info(`Renaming table: ${FROM_TABLE} -> ${TO_TABLE}`); + await connection.schema.renameTable(FROM_TABLE, TO_TABLE); + }, + async function down(connection) { + const fromExists = await connection.schema.hasTable(FROM_TABLE); + const toExists = await connection.schema.hasTable(TO_TABLE); + + if (fromExists) { + logging.warn(`Skipping renaming table: ${FROM_TABLE} already exists`); + return; + } + + if (!toExists) { + logging.warn(`Skipping renaming table: ${TO_TABLE} does not exist`); + return; + } + + logging.info(`Renaming table: ${TO_TABLE} -> ${FROM_TABLE}`); + await connection.schema.renameTable(TO_TABLE, FROM_TABLE); + } +); diff --git a/ghost/core/core/server/data/schema/schema.js b/ghost/core/core/server/data/schema/schema.js index d0c6dece6b5..6784f485ed2 100644 --- a/ghost/core/core/server/data/schema/schema.js +++ b/ghost/core/core/server/data/schema/schema.js @@ -1170,7 +1170,7 @@ module.exports = { created_at: {type: 'dateTime', nullable: false}, updated_at: {type: 'dateTime', nullable: true} }, - welcome_email_automations: { + automations: { id: {type: 'string', maxlength: 24, nullable: false, primary: true}, status: {type: 'string', maxlength: 50, nullable: false, defaultTo: 'inactive', validations: {isIn: [['active', 'inactive']]}}, name: {type: 'string', maxlength: 191, nullable: false, unique: true}, @@ -1180,7 +1180,7 @@ module.exports = { }, welcome_email_automated_emails: { id: {type: 'string', maxlength: 24, nullable: false, primary: true}, - welcome_email_automation_id: {type: 'string', maxlength: 24, nullable: false, references: 'welcome_email_automations.id', constraintName: 'weae_automation_id_foreign', cascadeDelete: true}, + welcome_email_automation_id: {type: 'string', maxlength: 24, nullable: false, references: 'automations.id', constraintName: 'weae_automation_id_foreign', cascadeDelete: true}, next_welcome_email_automated_email_id: {type: 'string', maxlength: 24, nullable: true, references: 'welcome_email_automated_emails.id', constraintName: 'weae_next_email_id_foreign', cascadeDelete: false}, delay_days: {type: 'integer', nullable: false, unsigned: true}, subject: {type: 'string', maxlength: 300, nullable: false}, @@ -1194,7 +1194,7 @@ module.exports = { }, welcome_email_automation_runs: { id: {type: 'string', maxlength: 24, nullable: false, primary: true}, - welcome_email_automation_id: {type: 'string', maxlength: 24, nullable: false, references: 'welcome_email_automations.id', constraintName: 'wear_automation_id_foreign', cascadeDelete: true}, + welcome_email_automation_id: {type: 'string', maxlength: 24, nullable: false, references: 'automations.id', constraintName: 'wear_automation_id_foreign', cascadeDelete: true}, member_id: {type: 'string', maxlength: 24, nullable: false, references: 'members.id', constraintName: 'wear_member_id_foreign', cascadeDelete: true}, next_welcome_email_automated_email_id: {type: 'string', maxlength: 24, nullable: true, references: 'welcome_email_automated_emails.id', constraintName: 'wear_next_email_id_foreign', cascadeDelete: false}, ready_at: {type: 'dateTime', nullable: true}, diff --git a/ghost/core/core/server/models/welcome-email-automation.js b/ghost/core/core/server/models/automation.js similarity index 89% rename from ghost/core/core/server/models/welcome-email-automation.js rename to ghost/core/core/server/models/automation.js index 5e981e20006..8c51fc4abf8 100644 --- a/ghost/core/core/server/models/welcome-email-automation.js +++ b/ghost/core/core/server/models/automation.js @@ -4,8 +4,8 @@ const {MEMBER_WELCOME_EMAIL_SLUGS} = require('../services/member-welcome-emails/ const MEMBER_WELCOME_EMAIL_SLUG_SET = new Set(Object.values(MEMBER_WELCOME_EMAIL_SLUGS)); -const WelcomeEmailAutomation = ghostBookshelf.Model.extend({ - tableName: 'welcome_email_automations', +const Automation = ghostBookshelf.Model.extend({ + tableName: 'automations', defaults() { return { @@ -57,5 +57,5 @@ const WelcomeEmailAutomation = ghostBookshelf.Model.extend({ }); module.exports = { - WelcomeEmailAutomation: ghostBookshelf.model('WelcomeEmailAutomation', WelcomeEmailAutomation) + Automation: ghostBookshelf.model('Automation', Automation) }; diff --git a/ghost/core/core/server/models/index.js b/ghost/core/core/server/models/index.js index 4f590faf85d..dd9653cca3d 100644 --- a/ghost/core/core/server/models/index.js +++ b/ghost/core/core/server/models/index.js @@ -9,6 +9,7 @@ const {Action} = require('./action'); const {ApiKey, ApiKeys} = require('./api-key'); const {Author, Authors} = require('./author'); const {AutomatedEmailRecipient, AutomatedEmailRecipients} = require('./automated-email-recipient'); +const {Automation} = require('./automation'); const {Benefit, Benefits} = require('./benefit'); const {CollectionPost} = require('./collection-post'); const {Collection} = require('./collection'); @@ -75,7 +76,6 @@ const {User, Users} = require('./user'); const {Webhook, Webhooks} = require('./webhook'); const {WelcomeEmailAutomatedEmail} = require('./welcome-email-automated-email'); const {WelcomeEmailAutomationRun} = require('./welcome-email-automation-run'); -const {WelcomeEmailAutomation} = require('./welcome-email-automation'); // enable event listeners require('./base/listeners'); @@ -91,6 +91,7 @@ exports.Author = Author; exports.Authors = Authors; exports.AutomatedEmailRecipient = AutomatedEmailRecipient; exports.AutomatedEmailRecipients = AutomatedEmailRecipients; +exports.Automation = Automation; exports.Benefit = Benefit; exports.Benefits = Benefits; exports.CollectionPost = CollectionPost; @@ -188,7 +189,6 @@ exports.Webhook = Webhook; exports.Webhooks = Webhooks; exports.WelcomeEmailAutomatedEmail = WelcomeEmailAutomatedEmail; exports.WelcomeEmailAutomationRun = WelcomeEmailAutomationRun; -exports.WelcomeEmailAutomation = WelcomeEmailAutomation; function init() { // `init` used to be a necessary call, but now it's unnecessary. diff --git a/ghost/core/core/server/models/welcome-email-automated-email.js b/ghost/core/core/server/models/welcome-email-automated-email.js index c1d75e88a93..b5cb8a17d89 100644 --- a/ghost/core/core/server/models/welcome-email-automated-email.js +++ b/ghost/core/core/server/models/welcome-email-automated-email.js @@ -14,8 +14,8 @@ const WelcomeEmailAutomatedEmail = ghostBookshelf.Model.extend({ return this.belongsTo('EmailDesignSetting', 'email_design_setting_id', 'id'); }, - welcomeEmailAutomation() { - return this.belongsTo('WelcomeEmailAutomation', 'welcome_email_automation_id', 'id'); + automation() { + return this.belongsTo('Automation', 'welcome_email_automation_id', 'id'); }, nextWelcomeEmailAutomatedEmail() { diff --git a/ghost/core/core/server/models/welcome-email-automation-run.js b/ghost/core/core/server/models/welcome-email-automation-run.js index d91cd62c5e6..5db236e8c0a 100644 --- a/ghost/core/core/server/models/welcome-email-automation-run.js +++ b/ghost/core/core/server/models/welcome-email-automation-run.js @@ -9,8 +9,8 @@ const WelcomeEmailAutomationRun = ghostBookshelf.Model.extend({ }; }, - welcomeEmailAutomation() { - return this.belongsTo('WelcomeEmailAutomation', 'welcome_email_automation_id', 'id'); + automation() { + return this.belongsTo('Automation', 'welcome_email_automation_id', 'id'); }, member() { diff --git a/ghost/core/core/server/services/member-welcome-emails/service.js b/ghost/core/core/server/services/member-welcome-emails/service.js index 366372d57d0..af99f52cd2d 100644 --- a/ghost/core/core/server/services/member-welcome-emails/service.js +++ b/ghost/core/core/server/services/member-welcome-emails/service.js @@ -10,7 +10,7 @@ const settingsHelpers = require('../settings-helpers'); const EmailAddressParser = require('../email-address/email-address-parser'); const mail = require('../mail'); // @ts-expect-error type checker has trouble with the dynamic exporting in models -const {WelcomeEmailAutomation, WelcomeEmailAutomatedEmail, Newsletter} = require('../../models'); +const {Automation, WelcomeEmailAutomatedEmail, Newsletter} = require('../../models'); const MemberWelcomeEmailRenderer = require('./member-welcome-email-renderer'); const {MEMBER_WELCOME_EMAIL_LOG_KEY, MEMBER_WELCOME_EMAIL_TAG, MEMBER_WELCOME_EMAIL_SLUGS, MESSAGES} = require('./constants'); @@ -179,7 +179,7 @@ class MemberWelcomeEmailService { } async #loadWelcomeEmailsCollection() { - return WelcomeEmailAutomation.findAll({ + return Automation.findAll({ filter: WELCOME_EMAIL_FILTER, withRelated: ['welcomeEmailAutomatedEmail'] }); @@ -337,7 +337,7 @@ class MemberWelcomeEmailService { this.#defaultNewsletterSenderOptions = await this.#getDefaultNewsletterSenderOptions(); for (const [memberStatus, slug] of Object.entries(MEMBER_WELCOME_EMAIL_SLUGS)) { - const row = await WelcomeEmailAutomation.findOne({slug}, { + const row = await Automation.findOne({slug}, { withRelated: ['welcomeEmailAutomatedEmail', 'welcomeEmailAutomatedEmail.emailDesignSetting'] }); @@ -428,7 +428,7 @@ class MemberWelcomeEmailService { return false; } - const row = await WelcomeEmailAutomation.findOne({slug}, {withRelated: ['welcomeEmailAutomatedEmail']}); + const row = await Automation.findOne({slug}, {withRelated: ['welcomeEmailAutomatedEmail']}); if (!row) { return false; } @@ -438,7 +438,7 @@ class MemberWelcomeEmailService { async #renderWelcomeEmailPreview({automatedEmailId, subject, lexical, memberEmail = 'jamie@example.com'}) { // Still validate the automated email exists (for permission purposes) - const automation = await WelcomeEmailAutomation.findOne({id: automatedEmailId}, { + const automation = await Automation.findOne({id: automatedEmailId}, { withRelated: ['welcomeEmailAutomatedEmail', 'welcomeEmailAutomatedEmail.emailDesignSetting'] }); const automatedEmail = automation?.related('welcomeEmailAutomatedEmail'); diff --git a/ghost/core/core/server/services/members/api.js b/ghost/core/core/server/services/members/api.js index a7296b756bd..6ee7956cf95 100644 --- a/ghost/core/core/server/services/members/api.js +++ b/ghost/core/core/server/services/members/api.js @@ -242,7 +242,7 @@ function createApiInstance(config) { MemberFeedback: models.MemberFeedback, EmailSpamComplaintEvent: models.EmailSpamComplaintEvent, Outbox: models.Outbox, - WelcomeEmailAutomation: models.WelcomeEmailAutomation, + Automation: models.Automation, WelcomeEmailAutomationRun: models.WelcomeEmailAutomationRun, AutomatedEmailRecipient: models.AutomatedEmailRecipient, Gift: models.Gift diff --git a/ghost/core/core/server/services/members/members-api/members-api.js b/ghost/core/core/server/services/members/members-api/members-api.js index 90f81558443..4ab360f1625 100644 --- a/ghost/core/core/server/services/members/members-api/members-api.js +++ b/ghost/core/core/server/services/members/members-api/members-api.js @@ -65,7 +65,7 @@ module.exports = function MembersAPI({ Comment, MemberFeedback, Outbox, - WelcomeEmailAutomation, + Automation, WelcomeEmailAutomationRun, AutomatedEmailRecipient, Gift @@ -104,7 +104,7 @@ module.exports = function MembersAPI({ tokenService, newslettersService, productRepository, - WelcomeEmailAutomation, + Automation, WelcomeEmailAutomationRun, Member, MemberNewsletter, diff --git a/ghost/core/core/server/services/members/members-api/repositories/event-repository.js b/ghost/core/core/server/services/members/members-api/repositories/event-repository.js index ba9c67cbc15..4649d5e3056 100644 --- a/ghost/core/core/server/services/members/members-api/repositories/event-repository.js +++ b/ghost/core/core/server/services/members/members-api/repositories/event-repository.js @@ -1019,7 +1019,7 @@ module.exports = class EventRepository { async getAutomatedEmailSentEvents(options = {}, filter) { options = { ...options, - withRelated: ['member', 'automatedEmail.welcomeEmailAutomation'], + withRelated: ['member', 'automatedEmail.automation'], filter: 'custom:true', useBasicCount: true, mongoTransformer: chainTransformers( @@ -1035,10 +1035,10 @@ module.exports = class EventRepository { const data = models.map((model) => { const automatedEmail = model.related('automatedEmail'); - const automation = automatedEmail.related('welcomeEmailAutomation'); + const automation = automatedEmail.related('automation'); if (!automation || !automation.id) { throw new errors.InternalServerError({ - message: `Automated email recipient ${model.id} has no associated welcome email automation` + message: `Automated email recipient ${model.id} has no associated automation` }); } diff --git a/ghost/core/core/server/services/members/members-api/repositories/member-repository.js b/ghost/core/core/server/services/members/members-api/repositories/member-repository.js index 9551df91055..837d00fbe92 100644 --- a/ghost/core/core/server/services/members/members-api/repositories/member-repository.js +++ b/ghost/core/core/server/services/members/members-api/repositories/member-repository.js @@ -66,7 +66,7 @@ module.exports = class MemberRepository { * @param {any} deps.offersAPI * @param {ITokenService} deps.tokenService * @param {any} deps.newslettersService - * @param {any} deps.WelcomeEmailAutomation + * @param {any} deps.Automation * @param {any} deps.WelcomeEmailAutomationRun */ constructor({ @@ -87,7 +87,7 @@ module.exports = class MemberRepository { offersAPI, tokenService, newslettersService, - WelcomeEmailAutomation, + Automation, WelcomeEmailAutomationRun }) { this._Member = Member; @@ -107,7 +107,7 @@ module.exports = class MemberRepository { this._offersAPI = offersAPI; this.tokenService = tokenService; this._newslettersService = newslettersService; - this._WelcomeEmailAutomation = WelcomeEmailAutomation; + this._Automation = Automation; this._WelcomeEmailAutomationRun = WelcomeEmailAutomationRun; DomainEvents.subscribe(OfferRedemptionEvent, async function (event) { @@ -385,9 +385,9 @@ module.exports = class MemberRepository { const isGiftSignup = !stripeCustomer && memberData.status === 'gift'; let welcomeEmailToEnqueue = null; - if (this._WelcomeEmailAutomation && WELCOME_EMAIL_SOURCES.includes(source)) { + if (this._Automation && WELCOME_EMAIL_SOURCES.includes(source)) { const getActiveWelcomeEmailToEnqueue = async (slug) => { - const automation = await this._WelcomeEmailAutomation.findOne( + const automation = await this._Automation.findOne( {slug}, {...options, withRelated: ['welcomeEmailAutomatedEmail']} ); @@ -1520,8 +1520,8 @@ module.exports = class MemberRepository { let isPaidWelcomeEmailActive = false; let paidWelcomeAutomation = null; let paidWelcomeEmail = null; - if (shouldSendPaidWelcomeEmail && this._WelcomeEmailAutomation) { - paidWelcomeAutomation = await this._WelcomeEmailAutomation.findOne( + if (shouldSendPaidWelcomeEmail && this._Automation) { + paidWelcomeAutomation = await this._Automation.findOne( {slug: MEMBER_WELCOME_EMAIL_SLUGS.paid}, {...options, withRelated: ['welcomeEmailAutomatedEmail']} ); diff --git a/ghost/core/core/server/services/outbox/handlers/member-created.js b/ghost/core/core/server/services/outbox/handlers/member-created.js index ad80129d746..7e5b9a23fcf 100644 --- a/ghost/core/core/server/services/outbox/handlers/member-created.js +++ b/ghost/core/core/server/services/outbox/handlers/member-created.js @@ -1,7 +1,7 @@ const {OUTBOX_LOG_KEY} = require('../jobs/lib/constants'); const memberWelcomeEmailService = require('../../member-welcome-emails/service'); const logging = require('@tryghost/logging'); -const {WelcomeEmailAutomation, AutomatedEmailRecipient} = require('../../../models'); +const {Automation, AutomatedEmailRecipient} = require('../../../models'); const {MEMBER_WELCOME_EMAIL_SLUGS} = require('../../member-welcome-emails/constants'); const LOG_KEY = `${OUTBOX_LOG_KEY}[MEMBER-WELCOME-EMAIL]`; @@ -21,7 +21,7 @@ async function handle({payload}) { return; } - const automation = await WelcomeEmailAutomation.findOne({slug}, {withRelated: ['welcomeEmailAutomatedEmail']}); + const automation = await Automation.findOne({slug}, {withRelated: ['welcomeEmailAutomatedEmail']}); if (!automation) { logging.warn({ system: { diff --git a/ghost/core/core/server/services/welcome-email-automations/poll.js b/ghost/core/core/server/services/welcome-email-automations/poll.js index 5c6ca25d290..2ad98fc3fd3 100644 --- a/ghost/core/core/server/services/welcome-email-automations/poll.js +++ b/ghost/core/core/server/services/welcome-email-automations/poll.js @@ -55,7 +55,7 @@ async function fetchAndLockRuns() { return await db.knex.transaction(async (trx) => { /** @type {Run[]} */ const runs = await trx('welcome_email_automation_runs as r') - .join('welcome_email_automations as a', 'r.welcome_email_automation_id', 'a.id') + .join('automations as a', 'r.welcome_email_automation_id', 'a.id') .join('welcome_email_automated_emails as e', 'r.next_welcome_email_automated_email_id', 'e.id') .whereNotNull('r.next_welcome_email_automated_email_id') .where('r.ready_at', '<=', now) diff --git a/ghost/core/package.json b/ghost/core/package.json index bff1a0e0b13..026a5e021f5 100644 --- a/ghost/core/package.json +++ b/ghost/core/package.json @@ -1,6 +1,6 @@ { "name": "ghost", - "version": "6.36.1-rc.0", + "version": "6.37.0-rc.0", "description": "The professional publishing platform", "author": "Ghost Foundation", "homepage": "https://ghost.org", diff --git a/ghost/core/test/e2e-api/admin/automated-emails.test.js b/ghost/core/test/e2e-api/admin/automated-emails.test.js index a8e9518d0ea..8076efd5251 100644 --- a/ghost/core/test/e2e-api/admin/automated-emails.test.js +++ b/ghost/core/test/e2e-api/admin/automated-emails.test.js @@ -40,7 +40,7 @@ describe('Automated Emails API', function () { beforeEach(async function () { await dbUtils.truncate('brute'); await dbUtils.truncate('welcome_email_automated_emails'); - await dbUtils.truncate('welcome_email_automations'); + await dbUtils.truncate('automations'); }); describe('Browse', function () { diff --git a/ghost/core/test/e2e-api/admin/automations.test.js b/ghost/core/test/e2e-api/admin/automations.test.js index 063069e0b68..06b61ce2039 100644 --- a/ghost/core/test/e2e-api/admin/automations.test.js +++ b/ghost/core/test/e2e-api/admin/automations.test.js @@ -38,17 +38,17 @@ describe('Automations API', function () { describe('browse', function () { beforeEach(async function () { await dbUtils.truncate('welcome_email_automated_emails'); - await dbUtils.truncate('welcome_email_automations'); + await dbUtils.truncate('automations'); }); - it('returns welcome email automations ordered by creation time', async function () { - const second = await models.WelcomeEmailAutomation.add({ + it('returns automations ordered by creation time', async function () { + const second = await models.Automation.add({ name: 'Welcome Email (Premium)', slug: 'member-welcome-email-premium', status: 'inactive', created_at: new Date('2025-01-02T00:00:00Z') }); - const first = await models.WelcomeEmailAutomation.add({ + const first = await models.Automation.add({ name: 'Welcome Email (Free)', slug: 'member-welcome-email-free', status: 'active', diff --git a/ghost/core/test/e2e-api/members/gift-subscriptions.test.js b/ghost/core/test/e2e-api/members/gift-subscriptions.test.js index c62b43163c0..3e56ba50182 100644 --- a/ghost/core/test/e2e-api/members/gift-subscriptions.test.js +++ b/ghost/core/test/e2e-api/members/gift-subscriptions.test.js @@ -760,7 +760,7 @@ describe('Gift Subscriptions', function () { {slug: 'default-automated-email'}, {require: true} ); - freeWelcomeAutomation = await models.WelcomeEmailAutomation.add({ + freeWelcomeAutomation = await models.Automation.add({ name: 'Free welcome email', slug: 'member-welcome-email-free', status: 'active' @@ -772,7 +772,7 @@ describe('Gift Subscriptions', function () { lexical: JSON.stringify({root: {children: [{type: 'paragraph', children: [{text: 'Welcome'}]}]}}), email_design_setting_id: emailDesignSetting.id }); - paidWelcomeAutomation = await models.WelcomeEmailAutomation.add({ + paidWelcomeAutomation = await models.Automation.add({ name: 'Paid welcome email', slug: 'member-welcome-email-paid', status: 'active' @@ -862,7 +862,7 @@ describe('Gift Subscriptions', function () { for (const run of runs.models) { await models.WelcomeEmailAutomationRun.destroy({id: run.id}); } - await models.WelcomeEmailAutomation.destroy({id: automation.id}); + await models.Automation.destroy({id: automation.id}); } } }); @@ -1111,7 +1111,7 @@ describe('Gift Subscriptions', function () { {slug: 'default-automated-email'}, {require: true} ); - paidWelcomeAutomation = await models.WelcomeEmailAutomation.add({ + paidWelcomeAutomation = await models.Automation.add({ name: 'Paid welcome email', slug: 'member-welcome-email-paid', status: 'active' @@ -1159,7 +1159,7 @@ describe('Gift Subscriptions', function () { for (const run of runs.models) { await models.WelcomeEmailAutomationRun.destroy({id: run.id}); } - await models.WelcomeEmailAutomation.destroy({id: paidWelcomeAutomation.id}); + await models.Automation.destroy({id: paidWelcomeAutomation.id}); } } }); diff --git a/ghost/core/test/integration/exporter/exporter.test.js b/ghost/core/test/integration/exporter/exporter.test.js index 8600c3957e2..18969ae1905 100644 --- a/ghost/core/test/integration/exporter/exporter.test.js +++ b/ghost/core/test/integration/exporter/exporter.test.js @@ -26,6 +26,7 @@ describe('Exporter', function () { 'actions', 'api_keys', 'automated_email_recipients', + 'automations', 'benefits', 'brute', 'collections', @@ -102,8 +103,7 @@ describe('Exporter', function () { 'users', 'webhooks', 'welcome_email_automated_emails', - 'welcome_email_automation_runs', - 'welcome_email_automations' + 'welcome_email_automation_runs' ]; assertExists(exportData); diff --git a/ghost/core/test/integration/jobs/process-outbox.test.js b/ghost/core/test/integration/jobs/process-outbox.test.js index 65b44e496bf..9cb6c4b56e8 100644 --- a/ghost/core/test/integration/jobs/process-outbox.test.js +++ b/ghost/core/test/integration/jobs/process-outbox.test.js @@ -28,7 +28,7 @@ describe('Process Outbox Job', function () { afterEach(async function () { sinon.restore(); await db.knex('outbox').del(); - await db.knex('welcome_email_automations').where('slug', MEMBER_WELCOME_EMAIL_SLUGS.free).del(); + await db.knex('automations').where('slug', MEMBER_WELCOME_EMAIL_SLUGS.free).del(); try { await jobService.removeJob(JOB_NAME); } catch (err) { @@ -65,7 +65,7 @@ describe('Process Outbox Job', function () { }); const automationId = ObjectId().toHexString(); - await db.knex('welcome_email_automations').insert({ + await db.knex('automations').insert({ id: automationId, status: 'active', name: 'Free Member Welcome Email', diff --git a/ghost/core/test/integration/services/member-welcome-emails.test.js b/ghost/core/test/integration/services/member-welcome-emails.test.js index bbd7d8733ab..62d1541277a 100644 --- a/ghost/core/test/integration/services/member-welcome-emails.test.js +++ b/ghost/core/test/integration/services/member-welcome-emails.test.js @@ -68,7 +68,7 @@ describe('Member Welcome Emails Integration', function () { }); const freeAutomationId = ObjectId().toHexString(); - await db.knex('welcome_email_automations').insert({ + await db.knex('automations').insert({ id: freeAutomationId, status: 'active', name: 'Free Member Welcome Email', @@ -86,7 +86,7 @@ describe('Member Welcome Emails Integration', function () { }); const paidAutomationId = ObjectId().toHexString(); - await db.knex('welcome_email_automations').insert({ + await db.knex('automations').insert({ id: paidAutomationId, status: 'active', name: 'Paid Member Welcome Email', @@ -120,8 +120,8 @@ describe('Member Welcome Emails Integration', function () { await db.knex('automated_email_recipients').del(); await db.knex('outbox').del(); await db.knex('members').del(); - await db.knex('welcome_email_automations').where('slug', MEMBER_WELCOME_EMAIL_SLUGS.free).del(); - await db.knex('welcome_email_automations').where('slug', MEMBER_WELCOME_EMAIL_SLUGS.paid).del(); + await db.knex('automations').where('slug', MEMBER_WELCOME_EMAIL_SLUGS.free).del(); + await db.knex('automations').where('slug', MEMBER_WELCOME_EMAIL_SLUGS.paid).del(); }); describe('Member creation with welcome emails', function () { @@ -211,13 +211,13 @@ describe('Member Welcome Emails Integration', function () { async function getAutomatedEmailBySlug(slug) { return db.knex('welcome_email_automated_emails') - .join('welcome_email_automations', 'welcome_email_automated_emails.welcome_email_automation_id', 'welcome_email_automations.id') - .where('welcome_email_automations.slug', slug) + .join('automations', 'welcome_email_automated_emails.welcome_email_automation_id', 'automations.id') + .where('automations.slug', slug) .first('welcome_email_automated_emails.*'); } it('does not send email when template is inactive', async function () { - await db.knex('welcome_email_automations') + await db.knex('automations') .where('slug', MEMBER_WELCOME_EMAIL_SLUGS.free) .update({status: 'inactive'}); @@ -243,7 +243,7 @@ describe('Member Welcome Emails Integration', function () { }); it('does not send email when no template exists', async function () { - await db.knex('welcome_email_automations').where('slug', MEMBER_WELCOME_EMAIL_SLUGS.free).del(); + await db.knex('automations').where('slug', MEMBER_WELCOME_EMAIL_SLUGS.free).del(); await models.Outbox.add({ event_type: 'MemberCreatedEvent', @@ -267,7 +267,7 @@ describe('Member Welcome Emails Integration', function () { }); it('does not send email when paid template is inactive but entry has status paid', async function () { - await db.knex('welcome_email_automations') + await db.knex('automations') .where('slug', MEMBER_WELCOME_EMAIL_SLUGS.paid) .update({status: 'inactive'}); @@ -293,7 +293,7 @@ describe('Member Welcome Emails Integration', function () { }); it('does not send email when no paid template exists but entry has status paid', async function () { - await db.knex('welcome_email_automations').where('slug', MEMBER_WELCOME_EMAIL_SLUGS.paid).del(); + await db.knex('automations').where('slug', MEMBER_WELCOME_EMAIL_SLUGS.paid).del(); await models.Outbox.add({ event_type: 'MemberCreatedEvent', @@ -350,8 +350,8 @@ describe('Member Welcome Emails Integration', function () { assert.equal(record.member_name, memberName); const automatedEmail = await db.knex('welcome_email_automated_emails') - .join('welcome_email_automations', 'welcome_email_automated_emails.welcome_email_automation_id', 'welcome_email_automations.id') - .where('welcome_email_automations.slug', MEMBER_WELCOME_EMAIL_SLUGS.free) + .join('automations', 'welcome_email_automated_emails.welcome_email_automation_id', 'automations.id') + .where('automations.slug', MEMBER_WELCOME_EMAIL_SLUGS.free) .first('welcome_email_automated_emails.id'); assert.equal(record.automated_email_id, automatedEmail.id); }); @@ -454,7 +454,7 @@ describe('Member Welcome Emails Integration', function () { }); it('uses mock member UUID when sending test welcome emails', async function () { - const automation = await db.knex('welcome_email_automations') + const automation = await db.knex('automations') .where('slug', MEMBER_WELCOME_EMAIL_SLUGS.free) .first(); @@ -492,7 +492,7 @@ describe('Member Welcome Emails Integration', function () { it('uses automated sender overrides for test welcome emails', async function () { memberWelcomeEmailService.init(); - const automation = await db.knex('welcome_email_automations') + const automation = await db.knex('automations') .where('slug', MEMBER_WELCOME_EMAIL_SLUGS.free) .first(); const automatedEmail = await getAutomatedEmailBySlug(MEMBER_WELCOME_EMAIL_SLUGS.free); diff --git a/ghost/core/test/integration/services/welcome-email-automations/poll.test.js b/ghost/core/test/integration/services/welcome-email-automations/poll.test.js index 5466a4329ef..1c4feaedca9 100644 --- a/ghost/core/test/integration/services/welcome-email-automations/poll.test.js +++ b/ghost/core/test/integration/services/welcome-email-automations/poll.test.js @@ -47,7 +47,7 @@ describe('welcome email automations poll', function () { await testUtils.knex('automated_email_recipients').del(); await testUtils.knex('welcome_email_automation_runs').del(); await testUtils.knex('welcome_email_automated_emails').del(); - await testUtils.knex('welcome_email_automations').del(); + await testUtils.knex('automations').del(); await testUtils.knex('members').del(); await testUtils.knex('email_design_settings') .where('slug', 'like', 'default-automated-email-%') @@ -105,7 +105,7 @@ describe('welcome email automations poll', function () { async function createAutomation(attrs = {}) { const currentTime = new Date(); - return insert('welcome_email_automations', { + return insert('automations', { id: ObjectId().toHexString(), status: 'active', name: `Automation ${ObjectId().toHexString()}`, diff --git a/ghost/core/test/unit/api/endpoints/automations.test.js b/ghost/core/test/unit/api/endpoints/automations.test.js index 2d4fa98304f..9d1a07cdc94 100644 --- a/ghost/core/test/unit/api/endpoints/automations.test.js +++ b/ghost/core/test/unit/api/endpoints/automations.test.js @@ -32,7 +32,7 @@ describe('Automations controller', function () { let dispatchStub; beforeEach(function () { - sinon.stub(models.WelcomeEmailAutomation, 'findAll').resolves([ + sinon.stub(models.Automation, 'findAll').resolves([ createMockAutomation('automation-id-1', 'Welcome Email (Free)', 'member-welcome-email-free', 'active'), createMockAutomation('automation-id-2', 'Welcome Email (Premium)', 'member-welcome-email-premium', 'inactive') ]); diff --git a/ghost/core/test/unit/server/data/schema/integrity.test.js b/ghost/core/test/unit/server/data/schema/integrity.test.js index 7ffc629a390..b38f7014997 100644 --- a/ghost/core/test/unit/server/data/schema/integrity.test.js +++ b/ghost/core/test/unit/server/data/schema/integrity.test.js @@ -35,7 +35,7 @@ const validateRouteSettings = require('../../../../../core/server/services/route */ describe('DB version integrity', function () { // Only these variables should need updating - const currentSchemaHash = '20b3032b2ec14edfdac13d1485391f19'; + const currentSchemaHash = '18ba143abafc26bd470027c8a7b9c245'; const currentFixturesHash = 'b76d01321e02fb99b11e7a29f91859f7'; const currentSettingsHash = '857b77a8e1c7072d9eb639152c78a49e'; const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01'; diff --git a/ghost/core/test/unit/server/models/welcome-email-automation.test.js b/ghost/core/test/unit/server/models/automation.test.js similarity index 86% rename from ghost/core/test/unit/server/models/welcome-email-automation.test.js rename to ghost/core/test/unit/server/models/automation.test.js index 563c785ba9f..cf12efc2d18 100644 --- a/ghost/core/test/unit/server/models/welcome-email-automation.test.js +++ b/ghost/core/test/unit/server/models/automation.test.js @@ -3,21 +3,21 @@ const sinon = require('sinon'); const models = require('../../../../core/server/models'); const logging = require('@tryghost/logging'); -describe('Unit: models/welcome-email-automation', function () { +describe('Unit: models/automation', function () { afterEach(function () { sinon.restore(); }); describe('defaults', function () { it('sets default status to inactive', function () { - const model = new models.WelcomeEmailAutomation(); + const model = new models.Automation(); const defaults = model.defaults(); assert.equal(defaults.status, 'inactive'); }); it('returns expected default values', function () { - const model = new models.WelcomeEmailAutomation(); + const model = new models.Automation(); const defaults = model.defaults(); assert.ok(defaults); @@ -29,7 +29,7 @@ describe('Unit: models/welcome-email-automation', function () { describe('onSaved', function () { it('logs when a welcome email is enabled', function () { const infoStub = sinon.stub(logging, 'info'); - const model = models.WelcomeEmailAutomation.forge({ + const model = models.Automation.forge({ id: 'test-id', slug: 'member-welcome-email-free', status: 'active' @@ -46,7 +46,7 @@ describe('Unit: models/welcome-email-automation', function () { it('logs when a welcome email is disabled', function () { const infoStub = sinon.stub(logging, 'info'); - const model = models.WelcomeEmailAutomation.forge({ + const model = models.Automation.forge({ id: 'test-id', slug: 'member-welcome-email-paid', status: 'inactive' @@ -63,7 +63,7 @@ describe('Unit: models/welcome-email-automation', function () { it('does not log for non-welcome-email slugs', function () { const infoStub = sinon.stub(logging, 'info'); - const model = models.WelcomeEmailAutomation.forge({ + const model = models.Automation.forge({ id: 'test-id', slug: 'some-other-slug', status: 'active' @@ -77,7 +77,7 @@ describe('Unit: models/welcome-email-automation', function () { it('does not log when status has not changed', function () { const infoStub = sinon.stub(logging, 'info'); - const model = models.WelcomeEmailAutomation.forge({ + const model = models.Automation.forge({ id: 'test-id', slug: 'member-welcome-email-free', status: 'active' diff --git a/ghost/core/test/unit/server/models/welcome-email-automation-run.test.js b/ghost/core/test/unit/server/models/welcome-email-automation-run.test.js index 9d67d77f43e..603ac6b78e1 100644 --- a/ghost/core/test/unit/server/models/welcome-email-automation-run.test.js +++ b/ghost/core/test/unit/server/models/welcome-email-automation-run.test.js @@ -24,9 +24,9 @@ describe('Unit: models/welcome-email-automation-run', function () { }); describe('relationships', function () { - it('has a welcomeEmailAutomation relationship', function () { + it('has an automation relationship', function () { const model = new models.WelcomeEmailAutomationRun(); - assert.equal(typeof model.welcomeEmailAutomation, 'function'); + assert.equal(typeof model.automation, 'function'); }); it('has a member relationship', function () { diff --git a/ghost/core/test/unit/server/services/members/members-api/members-api.test.js b/ghost/core/test/unit/server/services/members/members-api/members-api.test.js index 62a6bdf8a58..2d299f92adf 100644 --- a/ghost/core/test/unit/server/services/members/members-api/members-api.test.js +++ b/ghost/core/test/unit/server/services/members/members-api/members-api.test.js @@ -130,7 +130,7 @@ describe('MembersAPI', function () { Comment: {}, MemberFeedback: {}, Outbox: {}, - WelcomeEmailAutomation: {}, + Automation: {}, AutomatedEmailRecipient: {}, Gift: {} }, diff --git a/ghost/core/test/unit/server/services/members/members-api/repositories/event-repository.test.js b/ghost/core/test/unit/server/services/members/members-api/repositories/event-repository.test.js index 6242378d910..9771a8f1a3b 100644 --- a/ghost/core/test/unit/server/services/members/members-api/repositories/event-repository.test.js +++ b/ghost/core/test/unit/server/services/members/members-api/repositories/event-repository.test.js @@ -317,7 +317,7 @@ describe('EventRepository', function () { return { id: 'ae123', related: (rel) => { - if (rel === 'welcomeEmailAutomation') { + if (rel === 'automation') { return { id: 'auto123', get: key => (key === 'slug' ? 'member-welcome-email-free' : undefined) @@ -356,7 +356,7 @@ describe('EventRepository', function () { }); sinon.assert.calledOnceWithMatch(fake, { - withRelated: ['member', 'automatedEmail.welcomeEmailAutomation'], + withRelated: ['member', 'automatedEmail.automation'], filter: 'custom:true', order: 'created_at desc, id desc' }); @@ -370,7 +370,7 @@ describe('EventRepository', function () { }); sinon.assert.calledOnceWithMatch(fake, { - withRelated: ['member', 'automatedEmail.welcomeEmailAutomation'], + withRelated: ['member', 'automatedEmail.automation'], filter: 'custom:true', order: 'created_at desc, id desc' }); @@ -385,7 +385,7 @@ describe('EventRepository', function () { }); sinon.assert.calledOnceWithMatch(fake, { - withRelated: ['member', 'automatedEmail.welcomeEmailAutomation'], + withRelated: ['member', 'automatedEmail.automation'], filter: 'custom:true', order: 'created_at desc, id desc' }); diff --git a/ghost/core/test/unit/server/services/members/members-api/repositories/member-repository.test.js b/ghost/core/test/unit/server/services/members/members-api/repositories/member-repository.test.js index edc9be182ae..df720c265b9 100644 --- a/ghost/core/test/unit/server/services/members/members-api/repositories/member-repository.test.js +++ b/ghost/core/test/unit/server/services/members/members-api/repositories/member-repository.test.js @@ -1455,7 +1455,7 @@ describe('MemberRepository', function () { let MemberStatusEvent; let MemberSubscribeEvent; let newslettersService; - let WelcomeEmailAutomation; + let Automation; const oldNodeEnv = process.env.NODE_ENV; beforeEach(function () { @@ -1513,7 +1513,7 @@ describe('MemberRepository', function () { getAll: sinon.stub().resolves([]) }; - WelcomeEmailAutomation = { + Automation = { findOne: sinon.stub().resolves({ id: 'automation_id_free', get: sinon.stub().callsFake((key) => { @@ -1546,7 +1546,7 @@ describe('MemberRepository', function () { MemberStatusEvent, MemberSubscribeEventModel: MemberSubscribeEvent, newslettersService, - WelcomeEmailAutomation, + Automation, OfferRedemption: mockOfferRedemption }); @@ -1565,7 +1565,7 @@ describe('MemberRepository', function () { it('creates automation run for gift member signup (paid welcome email)', async function () { // Override stub with paid welcome email - WelcomeEmailAutomation.findOne = sinon.stub().resolves({ + Automation.findOne = sinon.stub().resolves({ id: 'automation_id_paid', get: sinon.stub().callsFake((key) => { const data = {status: 'active'}; @@ -1590,14 +1590,14 @@ describe('MemberRepository', function () { MemberStatusEvent, MemberSubscribeEventModel: MemberSubscribeEvent, newslettersService, - WelcomeEmailAutomation, + Automation, OfferRedemption: mockOfferRedemption }); await repo.create({email: 'test@example.com', name: 'Test Member', status: 'gift'}, {}); - sinon.assert.calledOnce(WelcomeEmailAutomation.findOne); - assert.equal(WelcomeEmailAutomation.findOne.firstCall.args[0].slug, 'member-welcome-email-paid'); + sinon.assert.calledOnce(Automation.findOne); + assert.equal(Automation.findOne.firstCall.args[0].slug, 'member-welcome-email-paid'); sinon.assert.calledOnce(WelcomeEmailAutomationRun.add); const runCall = WelcomeEmailAutomationRun.add.firstCall.args[0]; @@ -1608,7 +1608,7 @@ describe('MemberRepository', function () { it('does NOT create automation run for a gift signup when the paid welcome email is inactive', async function () { // Override stub with inactive paid welcome email - WelcomeEmailAutomation.findOne = sinon.stub().resolves({ + Automation.findOne = sinon.stub().resolves({ id: 'automation_id_paid', get: sinon.stub().callsFake((key) => { const data = {status: 'inactive'}; @@ -1630,7 +1630,7 @@ describe('MemberRepository', function () { MemberStatusEvent, MemberSubscribeEventModel: MemberSubscribeEvent, newslettersService, - WelcomeEmailAutomation, + Automation, OfferRedemption: mockOfferRedemption }); @@ -1648,7 +1648,7 @@ describe('MemberRepository', function () { MemberStatusEvent, MemberSubscribeEventModel: MemberSubscribeEvent, newslettersService, - WelcomeEmailAutomation, + Automation, OfferRedemption: mockOfferRedemption }); @@ -1673,7 +1673,7 @@ describe('MemberRepository', function () { MemberStatusEvent, MemberSubscribeEventModel: MemberSubscribeEvent, newslettersService, - WelcomeEmailAutomation, + Automation, OfferRedemption: mockOfferRedemption }); @@ -1684,7 +1684,7 @@ describe('MemberRepository', function () { }); it('does NOT create automation run when welcome email is inactive', async function () { - WelcomeEmailAutomation.findOne.resolves({ + Automation.findOne.resolves({ get: sinon.stub().callsFake((key) => { const data = {status: 'inactive'}; return data[key]; @@ -1707,7 +1707,7 @@ describe('MemberRepository', function () { MemberStatusEvent, MemberSubscribeEventModel: MemberSubscribeEvent, newslettersService, - WelcomeEmailAutomation, + Automation, OfferRedemption: mockOfferRedemption }); @@ -1728,7 +1728,7 @@ describe('MemberRepository', function () { MemberStatusEvent, MemberSubscribeEventModel: MemberSubscribeEvent, newslettersService, - WelcomeEmailAutomation, + Automation, StripeCustomer, OfferRedemption: mockOfferRedemption }); @@ -1757,7 +1757,7 @@ describe('MemberRepository', function () { // The free welcome email should NOT be sent when stripeCustomer is present sinon.assert.notCalled(WelcomeEmailAutomationRun.add); - sinon.assert.notCalled(WelcomeEmailAutomation.findOne); + sinon.assert.notCalled(Automation.findOne); sinon.assert.notCalled(Member.transaction); }); }); @@ -1772,7 +1772,7 @@ describe('MemberRepository', function () { let MemberStatusEvent; let stripeAPIService; let productRepository; - let WelcomeEmailAutomation; + let Automation; let subscriptionData; beforeEach(function () { @@ -1898,7 +1898,7 @@ describe('MemberRepository', function () { update: sinon.stub().resolves({}) }; - WelcomeEmailAutomation = { + Automation = { findOne: sinon.stub().resolves({ id: 'automation_id_paid', get: sinon.stub().callsFake((key) => { @@ -1943,7 +1943,7 @@ describe('MemberRepository', function () { MemberStatusEvent, stripeAPIService, productRepository, - WelcomeEmailAutomation, + Automation, OfferRedemption: mockOfferRedemption }); @@ -1990,7 +1990,7 @@ describe('MemberRepository', function () { MemberStatusEvent, stripeAPIService, productRepository, - WelcomeEmailAutomation, + Automation, OfferRedemption: mockOfferRedemption }); @@ -2027,7 +2027,7 @@ describe('MemberRepository', function () { }) }); - WelcomeEmailAutomation.findOne.resolves({ + Automation.findOne.resolves({ id: 'automation_id_paid', get: sinon.stub().callsFake((key) => { const data = {status: 'inactive'}; @@ -2055,7 +2055,7 @@ describe('MemberRepository', function () { MemberStatusEvent, stripeAPIService, productRepository, - WelcomeEmailAutomation, + Automation, OfferRedemption: mockOfferRedemption }); @@ -2094,7 +2094,7 @@ describe('MemberRepository', function () { MemberStatusEvent, stripeAPIService, productRepository, - WelcomeEmailAutomation, + Automation, OfferRedemption: mockOfferRedemption }); @@ -2119,7 +2119,7 @@ describe('MemberRepository', function () { let MemberStatusEvent; let MemberSubscribeEvent; let newslettersService; - let WelcomeEmailAutomation; + let Automation; let productRepository; let memberAdd; @@ -2152,7 +2152,7 @@ describe('MemberRepository', function () { getAll: sinon.stub().resolves([]) }; - WelcomeEmailAutomation = { + Automation = { findOne: sinon.stub().resolves(null) }; @@ -2169,7 +2169,7 @@ describe('MemberRepository', function () { MemberStatusEvent, MemberSubscribeEventModel: MemberSubscribeEvent, newslettersService, - WelcomeEmailAutomation, + Automation, productRepository, OfferRedemption: mockOfferRedemption }); @@ -2282,7 +2282,7 @@ describe('MemberRepository', function () { let MemberStatusEvent; let MemberSubscribeEvent; let newslettersService; - let WelcomeEmailAutomation; + let Automation; let productRepository; let stripeAPIService; let memberEdit; @@ -2355,7 +2355,7 @@ describe('MemberRepository', function () { getAll: sinon.stub().resolves([]) }; - WelcomeEmailAutomation = { + Automation = { findOne: sinon.stub().resolves(null) }; @@ -2377,7 +2377,7 @@ describe('MemberRepository', function () { MemberStatusEvent, MemberSubscribeEventModel: MemberSubscribeEvent, newslettersService, - WelcomeEmailAutomation, + Automation, productRepository, stripeAPIService, OfferRedemption: mockOfferRedemption diff --git a/ghost/core/test/unit/server/services/outbox/handlers/member-created.test.js b/ghost/core/test/unit/server/services/outbox/handlers/member-created.test.js index 96425b50bd5..9d9d2987602 100644 --- a/ghost/core/test/unit/server/services/outbox/handlers/member-created.test.js +++ b/ghost/core/test/unit/server/services/outbox/handlers/member-created.test.js @@ -6,7 +6,7 @@ const {captureLoggerOutput, findByEvent} = require('../../../../../utils/logging describe('member-created handler', function () { let handler; let memberWelcomeEmailServiceStub; - let WelcomeEmailAutomationStub; + let AutomationStub; let AutomatedEmailRecipientStub; let logCapture; @@ -19,7 +19,7 @@ describe('member-created handler', function () { } }; - WelcomeEmailAutomationStub = { + AutomationStub = { findOne: sinon.stub().resolves({ id: 'automation123', related: sinon.stub().callsFake((relation) => { @@ -37,7 +37,7 @@ describe('member-created handler', function () { logCapture = captureLoggerOutput(); handler.__set__('memberWelcomeEmailService', memberWelcomeEmailServiceStub); - handler.__set__('WelcomeEmailAutomation', WelcomeEmailAutomationStub); + handler.__set__('Automation', AutomationStub); handler.__set__('AutomatedEmailRecipient', AutomatedEmailRecipientStub); }); @@ -102,7 +102,7 @@ describe('member-created handler', function () { }); it('logs warning when no automated email found for slug', async function () { - WelcomeEmailAutomationStub.findOne.resolves(null); + AutomationStub.findOne.resolves(null); await handler.handle({ payload: {