Changed /email_previews/posts/<post id> endpoint to return 204 upon success

refs https://github.com/TryGhost/Toolbox/issues/308

- this endpoint is currently used to send a test email with the post
- it currently returns a 200 with whatever the response of the mail
  service is
- this body isn't used in Admin nor is useful generally because it just
  contains the ID of the mailgun response
- it's better than we change it to 204 and no response
- this commit does that and updates the tests
This commit is contained in:
Daniel Lockyer 2022-04-26 11:55:15 +01:00
parent b123a9bb77
commit f82ff87177
No known key found for this signature in database
GPG Key ID: D21186F0B47295AD
4 changed files with 4 additions and 21 deletions

View File

@ -43,7 +43,7 @@ module.exports = {
} }
}, },
sendTestEmail: { sendTestEmail: {
statusCode: 200, statusCode: 204,
headers: {}, headers: {},
options: [ options: [
'id' 'id'

View File

@ -1,7 +0,0 @@
module.exports = {
// @TODO remove for 5.0
// This should be a default serializer, not a passthrough, as per the read endpoint
sendTestEmail(data, apiConfig, frame) {
frame.response = data;
}
};

View File

@ -109,10 +109,6 @@ module.exports = {
return require('./site'); return require('./site');
}, },
get email_previews() {
return require('./email-previews');
},
get custom_theme_settings() { get custom_theme_settings() {
return require('./custom-theme-settings'); return require('./custom-theme-settings');
}, },

View File

@ -139,10 +139,8 @@ describe('Email Preview API', function () {
.send({ .send({
emails: ['test@ghost.org'] emails: ['test@ghost.org']
}) })
.set('Accept', 'application/json')
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private) .expect('Cache-Control', testUtils.cacheRules.private)
.expect(200) .expect(204)
.expect((res) => { .expect((res) => {
res.body.should.be.empty(); res.body.should.be.empty();
}); });
@ -168,10 +166,8 @@ describe('Email Preview API', function () {
.send({ .send({
emails: ['test@ghost.org'] emails: ['test@ghost.org']
}) })
.set('Accept', 'application/json')
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private) .expect('Cache-Control', testUtils.cacheRules.private)
.expect(200) .expect(204)
.expect((res) => { .expect((res) => {
res.body.should.be.empty(); res.body.should.be.empty();
}); });
@ -199,10 +195,8 @@ describe('Email Preview API', function () {
.send({ .send({
emails: ['test@ghost.org'] emails: ['test@ghost.org']
}) })
.set('Accept', 'application/json')
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private) .expect('Cache-Control', testUtils.cacheRules.private)
.expect(200) .expect(204)
.expect((res) => { .expect((res) => {
res.body.should.be.empty(); res.body.should.be.empty();
}); });