diff --git a/test/api/v3/integration/webhook/PUT-user_update_webhook.test.js b/test/api/v3/integration/webhook/PUT-user_update_webhook.test.js index 7745872984..f0fcaf9ad2 100644 --- a/test/api/v3/integration/webhook/PUT-user_update_webhook.test.js +++ b/test/api/v3/integration/webhook/PUT-user_update_webhook.test.js @@ -127,19 +127,26 @@ describe('PUT /user/webhook/:id', () => { it('can update taskActivity options', async () => { const type = 'taskActivity'; const options = { + checklistScored: true, updated: false, - deleted: true, + scored: false, }; - - const webhook = await user.put(`/user/webhook/${webhookToUpdate.id}`, { type, options }); - - expect(webhook.options).to.eql({ - checklistScored: false, // starting value + const expected = { + checklistScored: true, created: true, // starting value updated: false, - deleted: true, - scored: true, // default value - }); + deleted: false, // starting value + scored: false, + }; + + const returnedWebhook = await user.put(`/user/webhook/${webhookToUpdate.id}`, { type, options }); + + await user.sync(); + + const savedWebhook = user.webhooks.find(hook => webhookToUpdate.id === hook.id); + + expect(returnedWebhook.options).to.eql(expected); + expect(savedWebhook.options).to.eql(expected); }); it('errors if taskActivity option is not a boolean', async () => { diff --git a/website/server/controllers/api-v3/webhook.js b/website/server/controllers/api-v3/webhook.js index 3336f0eaec..00b5bf54cb 100644 --- a/website/server/controllers/api-v3/webhook.js +++ b/website/server/controllers/api-v3/webhook.js @@ -223,6 +223,10 @@ api.updateWebhook = { webhook.formatOptions(res); + // Tell Mongoose that the webhook's options have been modified + // so it actually commits the options changes to the database + webhook.markModified('options'); + await user.save(); res.respond(200, webhook); },