0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00

Renamed /email_preview API endpoint to /email_previews

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

- we have a pattern of using plurals for API endpoints but it was missed
  when we implemented email previews
- this fixes that for v5 and updates the tests accordingly
- there's some cleanup here to fix the API controller name too which
  I'll add to the list
This commit is contained in:
Daniel Lockyer 2022-04-25 15:46:28 +01:00
parent 10874100ef
commit 8473298072
No known key found for this signature in database
GPG key ID: D21186F0B47295AD
2 changed files with 9 additions and 10 deletions

View file

@ -288,9 +288,8 @@ module.exports = function apiRoutes() {
router.get('/actions', mw.authAdminApi, http(api.actions.browse));
// ## Email Preview
// @TODO: rename to email_previews in 5.0
router.get('/email_preview/posts/:id', mw.authAdminApi, http(api.email_preview.read));
router.post('/email_preview/posts/:id', mw.authAdminApi, http(api.email_preview.sendTestEmail));
router.get('/email_previews/posts/:id', mw.authAdminApi, http(api.email_preview.read));
router.post('/email_previews/posts/:id', mw.authAdminApi, http(api.email_preview.sendTestEmail));
// ## Emails
router.get('/emails', mw.authAdminApi, http(api.emails.browse));

View file

@ -42,7 +42,7 @@ describe('Email Preview API', function () {
it('can read post email preview with fields', async function () {
const res = await request
.get(localUtils.API.getApiQuery(`email_preview/posts/${testUtils.DataGenerator.Content.posts[0].id}/`))
.get(localUtils.API.getApiQuery(`email_previews/posts/${testUtils.DataGenerator.Content.posts[0].id}/`))
.set('Origin', config.get('url'))
.set('Accept', 'application/json')
.expect('Content-Type', /json/)
@ -71,7 +71,7 @@ describe('Email Preview API', function () {
await models.Post.add(post, {context: {internal: true}});
const res = await request
.get(localUtils.API.getApiQuery(`email_preview/posts/${post.id}/`))
.get(localUtils.API.getApiQuery(`email_previews/posts/${post.id}/`))
.set('Origin', config.get('url'))
.set('Accept', 'application/json')
.expect('Content-Type', /json/)
@ -109,7 +109,7 @@ describe('Email Preview API', function () {
await models.Post.add(post, {context: {internal: true}});
const res = await request
.get(localUtils.API.getApiQuery(`email_preview/posts/${post.id}/`))
.get(localUtils.API.getApiQuery(`email_previews/posts/${post.id}/`))
.set('Origin', config.get('url'))
.set('Accept', 'application/json')
.expect('Content-Type', /json/)
@ -132,7 +132,7 @@ describe('Email Preview API', function () {
describe('As Owner', function () {
it('can send test email', async function () {
const url = localUtils.API.getApiQuery(`email_preview/posts/${testUtils.DataGenerator.Content.posts[0].id}/`);
const url = localUtils.API.getApiQuery(`email_previews/posts/${testUtils.DataGenerator.Content.posts[0].id}/`);
await request
.post(url)
.set('Origin', config.get('url'))
@ -161,7 +161,7 @@ describe('Email Preview API', function () {
});
it('can send test email', async function () {
const url = localUtils.API.getApiQuery(`email_preview/posts/${testUtils.DataGenerator.Content.posts[0].id}/`);
const url = localUtils.API.getApiQuery(`email_previews/posts/${testUtils.DataGenerator.Content.posts[0].id}/`);
await request
.post(url)
.set('Origin', config.get('url'))
@ -192,7 +192,7 @@ describe('Email Preview API', function () {
});
it('can send test email', async function () {
const url = localUtils.API.getApiQuery(`email_preview/posts/${testUtils.DataGenerator.Content.posts[0].id}/`);
const url = localUtils.API.getApiQuery(`email_previews/posts/${testUtils.DataGenerator.Content.posts[0].id}/`);
await request
.post(url)
.set('Origin', config.get('url'))
@ -223,7 +223,7 @@ describe('Email Preview API', function () {
});
it('cannot send test email', async function () {
const url = localUtils.API.getApiQuery(`email_preview/posts/${testUtils.DataGenerator.Content.posts[0].id}/`);
const url = localUtils.API.getApiQuery(`email_previews/posts/${testUtils.DataGenerator.Content.posts[0].id}/`);
await request
.post(url)
.set('Origin', config.get('url'))