0c59b948fa
no issue - cleans up unused tables `emails.{meta,stats}` - adds timestamp columns `email_recipients.{delivered_at,opened_at,failed_at}` that can be used for event timelines and basic stats aggregation - indexed because we want to sort by these columns to find the "latest event" when limiting Mailgun events API requests - adds aggregated stats columns `emails.{delivered_count,opened_count,failed_count}` - adds a composite index on `email_recipients.[email_id,member_email]` to dramatically speed up `email_recipient` update queries when processing events - modifies the db initialisation to support an `'@@INDEXES@@'` key in table schema definition for composite indexes
39 lines
1.3 KiB
JavaScript
39 lines
1.3 KiB
JavaScript
const should = require('should');
|
|
const supertest = require('supertest');
|
|
const testUtils = require('../../utils');
|
|
const config = require('../../../core/shared/config');
|
|
const localUtils = require('./utils');
|
|
|
|
const ghost = testUtils.startGhost;
|
|
|
|
describe('Email API', function () {
|
|
let request;
|
|
|
|
before(function () {
|
|
return ghost()
|
|
.then(function () {
|
|
request = supertest.agent(config.get('url'));
|
|
})
|
|
.then(function () {
|
|
return localUtils.doAuth(request, 'posts', 'emails');
|
|
});
|
|
});
|
|
|
|
it('Can read an email', function () {
|
|
return request
|
|
.get(localUtils.API.getApiQuery(`emails/${testUtils.DataGenerator.Content.emails[0].id}/`))
|
|
.set('Origin', config.get('url'))
|
|
.expect('Content-Type', /json/)
|
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
|
.expect(200)
|
|
.then((res) => {
|
|
should.not.exist(res.headers['x-cache-invalidate']);
|
|
const jsonResponse = res.body;
|
|
should.exist(jsonResponse);
|
|
should.exist(jsonResponse.emails);
|
|
jsonResponse.emails.should.have.length(1);
|
|
localUtils.API.checkResponse(jsonResponse.emails[0], 'email');
|
|
});
|
|
});
|
|
});
|