Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ Model.prototype.hasAndBelongsToMany = function(joinedModel, fieldDoc, leftKey, r

var linkModel;
if (thinky.models[link] === undefined) {
linkModel = thinky.createModel(link, {}); // Create a model, claim the namespace and create the table
linkModel = thinky.createModel(link, {}, options); // Create a model, claim the namespace and create the table
}
else {
linkModel = thinky.models[link];
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
"validator": "~ 3.22.1"
},
"devDependencies": {
"mocha": "~1.21.5"
"mocha": "^2.2.5",
"chai": "^3.2.0",
"chai-as-promised": "^5.1.0"
}
}
15 changes: 5 additions & 10 deletions test/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,16 +356,11 @@ describe("Joins", function() {


model.hasAndBelongsToMany(otherModel, "otherDoc", "id", "otherId", {init: false});
try{
model.hasAndBelongsToMany(anotherModel, "otherDoc", "id", "otherId");
}
catch(err) {
assert.equal(err.message, "The field `otherDoc` is already used by another relation.")
// Wait for the link table to be ready since we wont' drop/recreate the table
thinky.models[model._getModel()._joins["otherDoc"].link].once('ready', function() {
// TODO Remove when tableWait is implemented on the server
done();
})
try {
model.hasAndBelongsToMany(anotherModel, "otherDoc", "id", "otherId", {init: false});
} catch(err) {
assert.equal(err.message, "The field `otherDoc` is already used by another relation.");
done();
}
});
it('hasOne should throw if the first argument is not a model', function(done) {
Expand Down
Loading