mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-04-15 03:01:37 -05:00
Added bare bones functionality sending an email
refs https://github.com/TryGhost/Toolbox/issues/292 - Super happy path scenario which handles sending information with some basic incompatibility information - It's meant to be built up upon! More to follow :)
This commit is contained in:
parent
e66ef401bd
commit
a8333f22d8
2 changed files with 38 additions and 0 deletions
|
@ -0,0 +1,16 @@
|
|||
class APIVersionCompatibilityService {
|
||||
constructor({sendEmail}) {
|
||||
this.sendEmail = sendEmail;
|
||||
}
|
||||
|
||||
handleMismatch({acceptVersion, contentVersion, userAgent}) {
|
||||
const emailTemplate = `
|
||||
${userAgent} integration expected Ghost version: ${acceptVersion}
|
||||
Current Ghost version: ${contentVersion}
|
||||
`;
|
||||
|
||||
this.sendEmail(emailTemplate);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = APIVersionCompatibilityService;
|
|
@ -0,0 +1,22 @@
|
|||
const assert = require('assert');
|
||||
const sinon = require('sinon');
|
||||
const APIVersionCompatibilityService = require('../index');
|
||||
|
||||
describe('APIVersionCompatibilityService', function () {
|
||||
it('Sends an email to the instance owner when fresh accept-version header mismatch detected', async function () {
|
||||
const sendEmail = sinon.spy();
|
||||
const compatibilityService = new APIVersionCompatibilityService({
|
||||
sendEmail
|
||||
});
|
||||
|
||||
await compatibilityService.handleMismatch({
|
||||
acceptVersion: 'v4.5',
|
||||
contentVersion: 'v5.1',
|
||||
userAgent: 'Elaborate Fox'
|
||||
});
|
||||
|
||||
assert.equal(sendEmail.called, true);
|
||||
assert.match(sendEmail.args[0][0], /Elaborate Fox integration expected Ghost version: v4.5/);
|
||||
assert.match(sendEmail.args[0][0], /Current Ghost version: v5.1/);
|
||||
});
|
||||
});
|
Loading…
Add table
Reference in a new issue