Change response code of special settings API endpoints to 204

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

- these endpoints return no body but they were implemented to return a
  200 error code
- 204 would be more suitable so this commit changes that for v5
- also removes the passthrough serializer and updates the snapshots to
  reflect the changes
This commit is contained in:
Daniel Lockyer 2022-04-25 17:55:05 +01:00
parent ea3c927d94
commit a48d8427f4
No known key found for this signature in database
GPG Key ID: D21186F0B47295AD
4 changed files with 6 additions and 10 deletions

View File

@ -96,6 +96,7 @@ module.exports = {
}, },
updateMembersEmail: { updateMembersEmail: {
statusCode: 204,
permissions: { permissions: {
method: 'edit' method: 'edit'
}, },
@ -122,6 +123,7 @@ module.exports = {
}, },
disconnectStripeConnectIntegration: { disconnectStripeConnectIntegration: {
statusCode: 204,
permissions: { permissions: {
method: 'edit' method: 'edit'
}, },

View File

@ -86,7 +86,5 @@ module.exports = {
download: serializeData, download: serializeData,
upload: serializeData, upload: serializeData,
updateMembersEmail: passthrough,
validateMembersEmailUpdate: passthrough, validateMembersEmailUpdate: passthrough,
disconnectStripeConnectIntegration: passthrough
}; };

View File

@ -1127,10 +1127,8 @@ exports[`Settings API can do disconnectStripeConnectIntegration 1: [headers] 1`]
Object { Object {
"access-control-allow-origin": "http://127.0.0.1:2369", "access-control-allow-origin": "http://127.0.0.1:2369",
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0", "cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "2",
"content-type": "application/json; charset=utf-8",
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/, "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Origin, Accept-Encoding", "vary": "Origin",
"x-powered-by": "Express", "x-powered-by": "Express",
} }
`; `;
@ -1139,10 +1137,8 @@ exports[`Settings API can do updateMembersEmail 1: [headers] 1`] = `
Object { Object {
"access-control-allow-origin": "http://127.0.0.1:2369", "access-control-allow-origin": "http://127.0.0.1:2369",
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0", "cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "2",
"content-type": "application/json; charset=utf-8",
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/, "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Origin, Accept-Encoding", "vary": "Origin",
"x-powered-by": "Express", "x-powered-by": "Express",
} }
`; `;

View File

@ -171,7 +171,7 @@ describe('Settings API', function () {
email: 'test@test.com', email: 'test@test.com',
type: 'fromAddressUpdate' type: 'fromAddressUpdate'
}) })
.expectStatus(200) .expectStatus(204)
.expectEmptyBody() .expectEmptyBody()
.matchHeaderSnapshot({ .matchHeaderSnapshot({
etag: anyEtag etag: anyEtag
@ -206,7 +206,7 @@ describe('Settings API', function () {
it('can do disconnectStripeConnectIntegration', async function () { it('can do disconnectStripeConnectIntegration', async function () {
await agent await agent
.delete('/settings/stripe/connect/') .delete('/settings/stripe/connect/')
.expectStatus(200) .expectStatus(204)
.expectEmptyBody() .expectEmptyBody()
.matchHeaderSnapshot({ .matchHeaderSnapshot({
etag: anyEtag etag: anyEtag