Skip to content

Commit

Permalink
Add test case for saving instance with hasMany autofetch but no assoc…
Browse files Browse the repository at this point in the history
…iations.

Issue: #398
  • Loading branch information
dxg committed Jan 13, 2014
1 parent 89cc8a2 commit 87852f4
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions test/integration/association-hasmany.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
/**
Expand Down Expand Up @@ -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) {
Expand All @@ -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();
});
});
});
});
});
});

0 comments on commit 87852f4

Please sign in to comment.