Skip to content

Commit

Permalink
Fix bypassCollection2 inserts (closes #290)
Browse files Browse the repository at this point in the history
  • Loading branch information
aldeed committed Dec 15, 2015
1 parent 07dfa95 commit 91c6462
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions collection2.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,11 @@ _.each(['insert', 'update'], function(methodName) {
// But insert should always return an ID to match core behavior.
return methodName === "insert" ? self._makeNewID() : undefined;
}
} else {
// We still need to adjust args because insert does not take options
if (methodName === "insert" && typeof args[1] !== 'function') args.splice(1, 1);
}

return _super.apply(self, args);
};
});
Expand Down
21 changes: 21 additions & 0 deletions tests/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -1036,3 +1036,24 @@ if (Meteor.isClient) {
});
});
}

// bypassCollection2
if (Meteor.isServer) {
Tinytest.add('Collection2 - bypassCollection2', function (test) {
var id;

try {
id = books.insert({}, {bypassCollection2: true})
test.ok();
} catch (error) {
test.fail(error.message);
}

try {
books.update(id, {$set: {copies: 2}}, {bypassCollection2: true})
test.ok();
} catch (error) {
test.fail(error.message);
}
});
}

0 comments on commit 91c6462

Please sign in to comment.