From 97feab1002f75e286b822aa56ee20655e201de4f Mon Sep 17 00:00:00 2001 From: Fabien 'egg' O'Carroll Date: Thu, 16 Jul 2020 11:13:36 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fixed=20email=20newsletter=20set?= =?UTF-8?q?tings=20(#1641)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes https://github.com/TryGhost/Ghost/issues/12052 * Added breaking test for mailgun settings * 🐛 Fixed mailgun settings to always set a baseUrl This matches the functionality seen before the bulk_email_settings were split, where the baseUrl was set when any of the mailgun settings were. --- .../admin/app/components/gh-feature-flag.hbs | 2 +- .../app/components/gh-members-lab-setting.hbs | 2 ++ .../app/components/gh-members-lab-setting.js | 6 ++++ ghost/admin/app/templates/settings/labs.hbs | 5 +++- .../tests/acceptance/settings/labs-test.js | 29 ++++++++++++++++++- 5 files changed, 41 insertions(+), 3 deletions(-) diff --git a/ghost/admin/app/components/gh-feature-flag.hbs b/ghost/admin/app/components/gh-feature-flag.hbs index 4f1fc190d4..8a30291481 100644 --- a/ghost/admin/app/components/gh-feature-flag.hbs +++ b/ghost/admin/app/components/gh-feature-flag.hbs @@ -1,3 +1,3 @@ - + {{{yield}}} diff --git a/ghost/admin/app/components/gh-members-lab-setting.hbs b/ghost/admin/app/components/gh-members-lab-setting.hbs index 2544a30da0..6fbf9d8995 100644 --- a/ghost/admin/app/components/gh-members-lab-setting.hbs +++ b/ghost/admin/app/components/gh-members-lab-setting.hbs @@ -356,6 +356,7 @@ @value={{readonly this.mailgunSettings.domain}} @input={{action "setMailgunDomain"}} @class="mt1" + data-test-mailgun-domain-input={{true}} /> @@ -371,6 +372,7 @@ @value={{readonly this.mailgunSettings.apiKey}} @input={{action "setMailgunApiKey"}} @class="mt1 password" @autocomplete="new-password" + data-test-mailgun-api-key-input={{true}} /> Find your Mailgun API keys here » diff --git a/ghost/admin/app/components/gh-members-lab-setting.js b/ghost/admin/app/components/gh-members-lab-setting.js index 50d5a5dbf3..ec3588e7ff 100644 --- a/ghost/admin/app/components/gh-members-lab-setting.js +++ b/ghost/admin/app/components/gh-members-lab-setting.js @@ -136,10 +136,16 @@ export default Component.extend({ setMailgunDomain(event) { this.set('settings.mailgunDomain', event.target.value); + if (!this.get('settings.mailgunBaseUrl')) { + this.set('settings.mailgunBaseUrl', this.mailgunRegion.baseUrl); + } }, setMailgunApiKey(event) { this.set('settings.mailgunApiKey', event.target.value); + if (!this.get('settings.mailgunBaseUrl')) { + this.set('settings.mailgunBaseUrl', this.mailgunRegion.baseUrl); + } }, setMailgunRegion(region) { diff --git a/ghost/admin/app/templates/settings/labs.hbs b/ghost/admin/app/templates/settings/labs.hbs index be1c96e3fe..75cb16ba54 100644 --- a/ghost/admin/app/templates/settings/labs.hbs +++ b/ghost/admin/app/templates/settings/labs.hbs @@ -19,7 +19,9 @@
Create registered members and take subscription payments — Find out more
-
+
+ +
{{#liquid-if this.feature.labs.members}} @@ -36,6 +38,7 @@ @successText="Saved" @runningText="Saving" @class="gh-btn gh-btn-blue gh-btn-icon" + data-test-button="save-members-settings" /> {{/liquid-if}} diff --git a/ghost/admin/tests/acceptance/settings/labs-test.js b/ghost/admin/tests/acceptance/settings/labs-test.js index c737e029bc..6bb076ebb4 100644 --- a/ghost/admin/tests/acceptance/settings/labs-test.js +++ b/ghost/admin/tests/acceptance/settings/labs-test.js @@ -1,6 +1,6 @@ import {authenticateSession, invalidateSession} from 'ember-simple-auth/test-support'; import {beforeEach, describe, it} from 'mocha'; -import {click, currentURL, find, findAll} from '@ember/test-helpers'; +import {click, currentURL, fillIn, find, findAll} from '@ember/test-helpers'; import {expect} from 'chai'; import {fileUpload} from '../../helpers/file-upload'; import {setupApplicationTest} from 'ember-mocha'; @@ -304,4 +304,31 @@ describe('Acceptance: Settings - Labs', function () { expect(iframe.getAttribute('src')).to.have.string('/settings/routes/yaml/'); }); }); + + describe('When logged in as Owner', function () { + beforeEach(async function () { + let role = this.server.create('role', {name: 'Owner'}); + this.server.create('user', {roles: [role]}); + + return await authenticateSession(); + }); + + it.only('sets the mailgunBaseUrl to the default', async function () { + await visit('/settings/labs'); + + await click('[data-test-toggle="enable-members"]'); + + await click('[data-test-toggle-membersemail]'); + + await fillIn('[data-test-mailgun-api-key-input]', 'i_am_an_api_key'); + await fillIn('[data-test-mailgun-domain-input]', 'https://domain.tld'); + + await click('[data-test-button="save-members-settings"]'); + + let [lastRequest] = this.server.pretender.handledRequests.slice(-1); + let params = JSON.parse(lastRequest.requestBody); + + expect(params.settings.findBy('key', 'mailgun_base_url').value).not.to.equal(null); + }); + }); });