Skip to content

Commit

Permalink
test(query): repro #7182
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Nov 1, 2018
1 parent 5ba13a7 commit 320d5f8
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/query.test.js
Expand Up @@ -3197,4 +3197,21 @@ describe('Query', function() {
assert.equal(docs.length, 1);
});
});

it('function defaults run after query result is inited (gh-7182)', function() {
const schema = new Schema({ kind: String, hasDefault: String });
schema.path('hasDefault').default(function() {
return this.kind === 'test' ? 'success' : 'fail';
});

return co(function*() {
const Model = db.model('gh7182', schema);

yield Model.create({ kind: 'test' });
yield Model.updateOne({}, { $unset: { hasDefault: 1 } });

const doc = yield Model.findOne();
assert.equal(doc.hasDefault, 'success');
});
});
});

0 comments on commit 320d5f8

Please sign in to comment.