mirror of
https://github.com/outline/outline.git
synced 2026-11-23 06:11:04 +03:00
fix: Preserve existing values when optional update fields are omitted (#14344)
* fix: Preserve existing values when optional update fields are omitted * chore: Rename setDefined to fill * chore: Use fill in users.update and teamUpdater
This commit is contained in:
1 parent
ce439c893c
commit
9fe0c7ba2b
18 files changed
+275
-136
No files matched your search
@@ -256,6 +256,51 @@ describe("#webhookSubscriptions.update", () => {
|
||||
expect(webhook.enabled).toEqual(true);
|
||||
});
|
||||
|
||||
it("should preserve the signing secret when it is omitted", async () => {
|
||||
const user = await buildAdmin();
|
||||
const existingWebhook = await buildWebhookSubscription({
|
||||
createdById: user.id,
|
||||
teamId: user.teamId,
|
||||
secret: "Test secret",
|
||||
});
|
||||
|
||||
const res = await server.post("/api/webhookSubscriptions.update", user, {
|
||||
body: {
|
||||
id: existingWebhook.id,
|
||||
name: "Updated webhook name",
|
||||
url: existingWebhook.url,
|
||||
events: existingWebhook.events,
|
||||
},
|
||||
});
|
||||
|
||||
expect(res.status).toEqual(200);
|
||||
await existingWebhook.reload();
|
||||
expect(existingWebhook.secret).toEqual("Test secret");
|
||||
});
|
||||
|
||||
it("should clear the signing secret when it is empty", async () => {
|
||||
const user = await buildAdmin();
|
||||
const existingWebhook = await buildWebhookSubscription({
|
||||
createdById: user.id,
|
||||
teamId: user.teamId,
|
||||
secret: "Test secret",
|
||||
});
|
||||
|
||||
const res = await server.post("/api/webhookSubscriptions.update", user, {
|
||||
body: {
|
||||
id: existingWebhook.id,
|
||||
name: existingWebhook.name,
|
||||
url: existingWebhook.url,
|
||||
events: existingWebhook.events,
|
||||
secret: "",
|
||||
},
|
||||
});
|
||||
|
||||
expect(res.status).toEqual(200);
|
||||
await existingWebhook.reload();
|
||||
expect(existingWebhook.secret).toBeNull();
|
||||
});
|
||||
|
||||
it("should update a webhook subscription without a signing secret", async () => {
|
||||
const user = await buildAdmin();
|
||||
const name = "Updated webhook name";
|
||||
|
||||
@@ -161,7 +161,7 @@ router.post(
|
||||
url,
|
||||
events: compact(events),
|
||||
enabled: true,
|
||||
secret: isEmpty(secret) ? undefined : secret,
|
||||
secret: secret === "" ? null : secret,
|
||||
});
|
||||
|
||||
ctx.body = {
|
||||
|
||||
Reference in new issue
Block a user