From 5c9aa8debd5fec9abbb994377bd16cd8788f8b31 Mon Sep 17 00:00:00 2001 From: VLE2FE Date: Tue, 12 May 2020 12:26:26 +0200 Subject: [PATCH] added status to POST method --- src/routes/measurement.spec.ts | 3 ++- src/routes/measurement.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/routes/measurement.spec.ts b/src/routes/measurement.spec.ts index c1ed0fa..79d0606 100644 --- a/src/routes/measurement.spec.ts +++ b/src/routes/measurement.spec.ts @@ -82,9 +82,10 @@ describe('/measurement', () => { }).end((err, res) => { if (err) return done(err); MeasurementModel.findById(res.body._id).lean().exec((err, data: any) => { - should(data).have.only.keys('_id', 'condition_id', 'values', 'measurement_template', '__v'); + should(data).have.only.keys('_id', 'condition_id', 'values', 'measurement_template', 'status', '__v'); should(data.condition_id.toString()).be.eql('700000000000000000000001'); should(data.measurement_template.toString()).be.eql('300000000000000000000002'); + should(data).have.property('status', 0); should(data).have.property('values'); should(data.values).have.property('weight %', 0.8); should(data.values).have.property('standard deviation', 0.1); diff --git a/src/routes/measurement.ts b/src/routes/measurement.ts index 8dda6cd..9f7bf41 100644 --- a/src/routes/measurement.ts +++ b/src/routes/measurement.ts @@ -33,6 +33,7 @@ router.post('/measurement/new', async (req, res, next) => { if (!await conditionIdCheck(measurement, req, res, next)) return; if (!await templateCheck(measurement, 'new', res, next)) return; + measurement.status = await new MeasurementModel(measurement).save((err, data) => { if (err) return next(err); res.json(MeasurementValidate.output(data.toObject()));