From 87852f419200d2aa20ff614959fa1034a5030dce Mon Sep 17 00:00:00 2001 From: Arek W Date: Mon, 13 Jan 2014 20:24:33 +1100 Subject: [PATCH] Add test case for saving instance with hasMany autofetch but no associations. Issue: #398 --- test/integration/association-hasmany.js | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/test/integration/association-hasmany.js b/test/integration/association-hasmany.js index ad8b2afe..a7fab0e1 100644 --- a/test/integration/association-hasmany.js +++ b/test/integration/association-hasmany.js @@ -18,11 +18,11 @@ describe("hasMany", function () { name : String, surname : String, age : Number - }, opts); + }); Pet = db.define('pet', { name : String }); - Person.hasMany('pets', Pet); + Person.hasMany('pets', Pet, {}, { autoFetch: opts.autoFetchPets }); return helper.dropSync([ Person, Pet ], function () { /** @@ -512,7 +512,7 @@ describe("hasMany", function () { describe("with autoFetch turned on", function () { before(setup({ - autoFetch : true + autoFetchPets : true })); it("should fetch associations", function (done) { @@ -526,5 +526,23 @@ describe("hasMany", function () { return done(); }); }); + + it("should save existing", function (done) { + Person.create({ name: 'Bishan' }, function (err) { + should.not.exist(err); + + Person.one({ name: 'Bishan' }, function (err, person) { + should.not.exist(err); + + person.surname = 'Dominar'; + + person.save(function (err) { + should.not.exist(err); + + done(); + }); + }); + }); + }); }); });