diff --git a/changelog.md b/changelog.md index 11b354dcb..10899a485 100644 --- a/changelog.md +++ b/changelog.md @@ -61,7 +61,7 @@ pre { ## changelog For a full record of development, visit our [Github Page](https://github.com/naturalcrit/homebrewery). -### Friday 17/02/2023 - v3.6.1 +### Saturday 18/02/2023 - v3.6.1 {{taskList ##### G-Ambatte diff --git a/server/homebrew.api.js b/server/homebrew.api.js index 228a08128..6f5fcb1ef 100644 --- a/server/homebrew.api.js +++ b/server/homebrew.api.js @@ -317,13 +317,7 @@ If you believe you should have access to this brew, ask the file owner to invite brew.textBin = zlib.deflateRawSync(brew.text); brew.text = undefined; } - - // Otherwise, save the brew with updated author list - // markModified() is necessary to have Mongoose reduce the array length in the database - // Without it, starting with an array of ['A', 'B', 'C'] in the database: - // - when reduced to ['A', 'B'] will result in ['A', 'B', 'C'] saved in the database - // - when reduced to ['B', 'C'] will result in ['B', 'C', 'C'] saved in the database - brew.markModified('authors'); + brew.markModified('authors'); //Mongo will not properly update arrays without markModified() await brew.save() .catch((err)=>{ throw { status: 500, message: err }; diff --git a/server/homebrew.api.spec.js b/server/homebrew.api.spec.js index a244f01ef..ee00677d5 100644 --- a/server/homebrew.api.spec.js +++ b/server/homebrew.api.spec.js @@ -32,6 +32,7 @@ describe('Tests for api', ()=>{ delete this.save; delete this.toObject; delete this.remove; + delete this.markModified; return this; } }); @@ -444,7 +445,6 @@ brew`); description : '', editId : expect.any(String), gDrive : false, - markModified : expect.any(Function), pageCount : 1, published : false, renderer : 'V3', @@ -508,7 +508,6 @@ brew`); renderer : undefined, shareId : expect.any(String), googleId : expect.any(String), - markModified : expect.any(Function), style : undefined, systems : [], tags : [], @@ -722,7 +721,7 @@ brew`); await api.deleteBrew(req, res); expect(api.getBrew).toHaveBeenCalled(); - // expect(markModifiedFunc).toHaveBeenCalled(); + expect(markModifiedFunc).toHaveBeenCalled(); expect(model.findOne).toHaveBeenCalled(); expect(removeFunc).not.toHaveBeenCalled(); expect(api.deleteGoogleBrew).toHaveBeenCalled();