0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-25 02:31:59 -05:00

Added default stats object to email model

- The serialized object is meant to serve as a placeholder for future email related stats pooled from mail service provider
This commit is contained in:
Nazar Gargol 2019-11-08 17:11:54 +07:00
parent 0a17f5d3c0
commit 93b22af899
3 changed files with 18 additions and 2 deletions

View file

@ -7,7 +7,15 @@ const Email = ghostBookshelf.Model.extend({
defaults: function defaults() {
return {
uuid: uuid.v4(),
status: 'pending'
status: 'pending',
stats: JSON.stringify({
delivered: 0,
failed: 0,
opened: 0,
clicked: 0,
unsubscribed: 0,
complaints: 0
})
};
},

View file

@ -33,6 +33,15 @@ describe('Email API', function () {
should.exist(jsonResponse.emails);
jsonResponse.emails.should.have.length(1);
localUtils.API.checkResponse(jsonResponse.emails[0], 'email');
const stats = JSON.parse(jsonResponse.emails[0].stats);
should.exist(stats.delivered);
should.exist(stats.failed);
should.exist(stats.opened);
should.exist(stats.clicked);
should.exist(stats.unsubscribed);
should.exist(stats.complaints);
});
});
});

View file

@ -425,7 +425,6 @@ DataGenerator.Content = {
id: ObjectId.generate(),
uuid: '6b6afda6-4b5e-4893-bff6-f16859e8349a',
status: 'submitted',
stats: '',
email_count: 2,
subject: 'You got mailed!',
html: '<p>Look! I\'m an email</p>',