diff --git a/ghost/admin/mirage/config/newsletters.js b/ghost/admin/mirage/config/newsletters.js index 04e23c5750..8966761d84 100644 --- a/ghost/admin/mirage/config/newsletters.js +++ b/ghost/admin/mirage/config/newsletters.js @@ -1,4 +1,6 @@ import {camelize} from '@ember/string'; +import {dasherize} from '@ember/string'; +import {isBlank} from '@ember/utils'; import {paginatedResponse} from '../utils'; export default function mockNewsletters(server) { @@ -12,6 +14,10 @@ export default function mockNewsletters(server) { const senderEmail = attrs.senderEmail; attrs.senderEmail = null; + if (isBlank(attrs.slug) && !isBlank(attrs.name)) { + attrs.slug = dasherize(attrs.name); + } + const newsletter = newsletters.create(attrs); // workaround for mirage output of meta diff --git a/ghost/admin/tests/acceptance/settings/newsletters-test.js b/ghost/admin/tests/acceptance/settings/newsletters-test.js index f1dc925188..b5f8a0ca19 100644 --- a/ghost/admin/tests/acceptance/settings/newsletters-test.js +++ b/ghost/admin/tests/acceptance/settings/newsletters-test.js @@ -153,7 +153,7 @@ describe('Acceptance: Settings - Newsletters', function () { await checkSave({}); - expect(findAll('[data-test-newsletter]').length, 'Total newsletters shown').to.equal(2); + expect(findAll('[data-test-newsletter]').length, 'Total newsletters shown afterwards').to.equal(2); }); it('validates create newsletter before saving', async function () { @@ -174,7 +174,7 @@ describe('Acceptance: Settings - Newsletters', function () { // Everything should be valid await checkSave({}); - expect(findAll('[data-test-newsletter]').length, 'Total newsletters shown').to.equal(2); + expect(findAll('[data-test-newsletter]').length, 'Total newsletters shown afterwards').to.equal(2); }); it('checks limits when creating a newsletter', async function () {