Archived
2

added status to POST method

This commit is contained in:
VLE2FE 2020-05-12 12:26:26 +02:00
parent a516062822
commit 5c9aa8debd
2 changed files with 3 additions and 1 deletions

View File

@ -82,9 +82,10 @@ describe('/measurement', () => {
}).end((err, res) => { }).end((err, res) => {
if (err) return done(err); if (err) return done(err);
MeasurementModel.findById(res.body._id).lean().exec((err, data: any) => { 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.condition_id.toString()).be.eql('700000000000000000000001');
should(data.measurement_template.toString()).be.eql('300000000000000000000002'); should(data.measurement_template.toString()).be.eql('300000000000000000000002');
should(data).have.property('status', 0);
should(data).have.property('values'); should(data).have.property('values');
should(data.values).have.property('weight %', 0.8); should(data.values).have.property('weight %', 0.8);
should(data.values).have.property('standard deviation', 0.1); should(data.values).have.property('standard deviation', 0.1);

View File

@ -33,6 +33,7 @@ router.post('/measurement/new', async (req, res, next) => {
if (!await conditionIdCheck(measurement, req, res, next)) return; if (!await conditionIdCheck(measurement, req, res, next)) return;
if (!await templateCheck(measurement, 'new', res, next)) return; if (!await templateCheck(measurement, 'new', res, next)) return;
measurement.status =
await new MeasurementModel(measurement).save((err, data) => { await new MeasurementModel(measurement).save((err, data) => {
if (err) return next(err); if (err) return next(err);
res.json(MeasurementValidate.output(data.toObject())); res.json(MeasurementValidate.output(data.toObject()));