🐛 Fixed email newsletter settings (#1641)

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.
This commit is contained in:
Fabien 'egg' O'Carroll 2020-07-16 11:13:36 +02:00 committed by GitHub
parent 4b0f1a18d6
commit 97feab1002
5 changed files with 41 additions and 3 deletions

View File

@ -1,3 +1,3 @@
<input type="checkbox" checked={{this.value}} disabled={{this.disabled}} id={{this.for}} name={{this.name}} onclick={{action (mut this.value) value="target.checked"}}> <input type="checkbox" data-test-toggle={{this.testKey}} checked={{this.value}} disabled={{this.disabled}} id={{this.for}} name={{this.name}} onclick={{action (mut this.value) value="target.checked"}}>
<span class="input-toggle-component"></span> <span class="input-toggle-component"></span>
{{{yield}}} {{{yield}}}

View File

@ -356,6 +356,7 @@
@value={{readonly this.mailgunSettings.domain}} @value={{readonly this.mailgunSettings.domain}}
@input={{action "setMailgunDomain"}} @input={{action "setMailgunDomain"}}
@class="mt1" @class="mt1"
data-test-mailgun-domain-input={{true}}
/> />
</GhFormGroup> </GhFormGroup>
</div> </div>
@ -371,6 +372,7 @@
@value={{readonly this.mailgunSettings.apiKey}} @value={{readonly this.mailgunSettings.apiKey}}
@input={{action "setMailgunApiKey"}} @input={{action "setMailgunApiKey"}}
@class="mt1 password" @autocomplete="new-password" @class="mt1 password" @autocomplete="new-password"
data-test-mailgun-api-key-input={{true}}
/> />
<a href="https://app.mailgun.com/app/account/security/api_keys" target="_blank" class="mt1 fw4 f8"> <a href="https://app.mailgun.com/app/account/security/api_keys" target="_blank" class="mt1 fw4 f8">
Find your Mailgun API keys here &raquo; Find your Mailgun API keys here &raquo;

View File

@ -136,10 +136,16 @@ export default Component.extend({
setMailgunDomain(event) { setMailgunDomain(event) {
this.set('settings.mailgunDomain', event.target.value); this.set('settings.mailgunDomain', event.target.value);
if (!this.get('settings.mailgunBaseUrl')) {
this.set('settings.mailgunBaseUrl', this.mailgunRegion.baseUrl);
}
}, },
setMailgunApiKey(event) { setMailgunApiKey(event) {
this.set('settings.mailgunApiKey', event.target.value); this.set('settings.mailgunApiKey', event.target.value);
if (!this.get('settings.mailgunBaseUrl')) {
this.set('settings.mailgunBaseUrl', this.mailgunRegion.baseUrl);
}
}, },
setMailgunRegion(region) { setMailgunRegion(region) {

View File

@ -19,7 +19,9 @@
<div class="gh-setting-desc pl5 pb5">Create registered members and take subscription payments — <a href="https://ghost.org/docs/members/" target="_blank" rel="noopener">Find out more</a></div> <div class="gh-setting-desc pl5 pb5">Create registered members and take subscription payments — <a href="https://ghost.org/docs/members/" target="_blank" rel="noopener">Find out more</a></div>
</div> </div>
<div class="gh-setting-action"> <div class="gh-setting-action">
<div class="for-switch pa5"><GhFeatureFlag @flag="members" /></div> <div class="for-switch pa5">
<GhFeatureFlag @flag="members" @testKey="enable-members"/>
</div>
</div> </div>
</div> </div>
{{#liquid-if this.feature.labs.members}} {{#liquid-if this.feature.labs.members}}
@ -36,6 +38,7 @@
@successText="Saved" @successText="Saved"
@runningText="Saving" @runningText="Saving"
@class="gh-btn gh-btn-blue gh-btn-icon" @class="gh-btn gh-btn-blue gh-btn-icon"
data-test-button="save-members-settings"
/> />
</div> </div>
{{/liquid-if}} {{/liquid-if}}

View File

@ -1,6 +1,6 @@
import {authenticateSession, invalidateSession} from 'ember-simple-auth/test-support'; import {authenticateSession, invalidateSession} from 'ember-simple-auth/test-support';
import {beforeEach, describe, it} from 'mocha'; 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 {expect} from 'chai';
import {fileUpload} from '../../helpers/file-upload'; import {fileUpload} from '../../helpers/file-upload';
import {setupApplicationTest} from 'ember-mocha'; import {setupApplicationTest} from 'ember-mocha';
@ -304,4 +304,31 @@ describe('Acceptance: Settings - Labs', function () {
expect(iframe.getAttribute('src')).to.have.string('/settings/routes/yaml/'); 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);
});
});
}); });