Skip to content

Commit

Permalink
test(model): repro #5779
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Nov 7, 2017
1 parent 3771f49 commit ab668da
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/versioning.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -526,4 +526,31 @@ describe('versioning', function() {
done();
});
});

it('copying doc works (gh-5779)', function(done) {
var schema = new Schema({ subdocs: [{ a: Number }] });
var M = db.model('gh5779', schema, 'gh5779');
var m = new M({ subdocs: [] });
var m2;

m.save().
then(function() {
m2 = new M(m);
m2.subdocs.push({ a: 2 });
return m2.save();
}).
then(function() {
m2.subdocs[0].a = 3;
return m2.save();
}).
then(function() {
assert.equal(m2.subdocs[0].a, 3);
return M.findById(m._id);
}).
then(function(doc) {
assert.equal(doc.subdocs[0].a, 3);
done();
}).
catch(done);
});
});

0 comments on commit ab668da

Please sign in to comment.