fix: Server error when attempting to update team with identical details to previous
This commit is contained in:
@ -37,17 +37,19 @@ router.post("team.update", auth(), async (ctx) => {
|
|||||||
|
|
||||||
await team.save();
|
await team.save();
|
||||||
|
|
||||||
for (const change of changes) {
|
if (changes) {
|
||||||
data[change] = team[change];
|
for (const change of changes) {
|
||||||
}
|
data[change] = team[change];
|
||||||
|
}
|
||||||
|
|
||||||
await Event.create({
|
await Event.create({
|
||||||
name: "teams.update",
|
name: "teams.update",
|
||||||
actorId: user.id,
|
actorId: user.id,
|
||||||
teamId: user.teamId,
|
teamId: user.teamId,
|
||||||
data,
|
data,
|
||||||
ip: ctx.request.ip,
|
ip: ctx.request.ip,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
ctx.body = {
|
ctx.body = {
|
||||||
data: presentTeam(team),
|
data: presentTeam(team),
|
||||||
|
@ -21,6 +21,17 @@ describe("#team.update", () => {
|
|||||||
expect(body.data.name).toEqual("New name");
|
expect(body.data.name).toEqual("New name");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should allow identical team details", async () => {
|
||||||
|
const { admin, team } = await seed();
|
||||||
|
const res = await server.post("/api/team.update", {
|
||||||
|
body: { token: admin.getJwtToken(), name: team.name },
|
||||||
|
});
|
||||||
|
const body = await res.json();
|
||||||
|
|
||||||
|
expect(res.status).toEqual(200);
|
||||||
|
expect(body.data.name).toEqual(team.name);
|
||||||
|
});
|
||||||
|
|
||||||
it("should require admin", async () => {
|
it("should require admin", async () => {
|
||||||
const { user } = await seed();
|
const { user } = await seed();
|
||||||
const res = await server.post("/api/team.update", {
|
const res = await server.post("/api/team.update", {
|
||||||
|
Reference in New Issue
Block a user