diff --git a/templates/endpoint/basename.controller.js b/templates/endpoint/basename.controller.js index 63279b423..a9b5fa74c 100644 --- a/templates/endpoint/basename.controller.js +++ b/templates/endpoint/basename.controller.js @@ -101,7 +101,7 @@ export function upsert(req, res) { delete req.body._id; } <%_ if(filters.mongooseModels) { -%> - return <%= classedName %>.findOneAndUpdate({_id: req.params.id}, req.body, {upsert: true, setDefaultsOnInsert: true, runValidators: true}).exec()<% } %> + return <%= classedName %>.findOneAndUpdate({_id: req.params.id}, req.body, {new: true, upsert: true, setDefaultsOnInsert: true, runValidators: true}).exec()<% } %> <%_ if(filters.sequelizeModels) { -%> return <%= classedName %>.upsert(req.body, { where: { diff --git a/templates/endpoint/basename.integration.js b/templates/endpoint/basename.integration.js index 9f5db9738..fafd3f483 100644 --- a/templates/endpoint/basename.integration.js +++ b/templates/endpoint/basename.integration.js @@ -105,9 +105,9 @@ describe('<%= classedName %> API:', function() { updated<%= classedName %> = {}; }); - it('should respond with the original <%= cameledName %>', function() { - <%= expect() %>updated<%= classedName %>.name<%= to() %>.equal('New <%= classedName %>'); - <%= expect() %>updated<%= classedName %>.info<%= to() %>.equal('This is the brand new <%= cameledName %>!!!'); + it('should respond with the updated <%= cameledName %>', function() { + <%= expect() %>updated<%= classedName %>.name<%= to() %>.equal('Updated <%= classedName %>'); + <%= expect() %>updated<%= classedName %>.info<%= to() %>.equal('This is the updated <%= cameledName %>!!!'); }); it('should respond with the updated <%= cameledName %> on a subsequent GET', function(done) {