Found in 0.7.2
If an attempt is made to insert a document with a pre-defined _id property, meteor transactions package overwrites this with its own randomly - generated _id value
The following test demonstrates this bug
'use strict';
describe('committable actions', function () {
var transaction_id, insertedFooDoc, transactionDoc, fakeId;
beforeEach(function () {
// Fake userId to get through tx userId checks
fakeId = 'or6YSgs6nT8Bs5o6p';
// Because `tx.requireUser = true` (by default)
spyOn(Meteor,'userId').and.returnValue(fakeId);
});
fit('insert with pre-defined document _id', function () {
// SETUP
var predefinedId = 'PNAJ67oTkkaH46xJz';
tx.start('insert transaction');
fooCollection.insert(
{_id: predefinedId, foo: "After insert"}, {tx: true});
// EXECUTE
tx.commit();
// VERIFY
var savedDoc = fooCollection.findOne({_id: predefinedId});
expect(savedDoc).toBeDefined();
expect(savedDoc.foo).toEqual('After insert');
});
afterEach(function () {
fooCollection.remove({});
tx.Transactions.remove({});
});
});
Found in 0.7.2 If an attempt is made to insert a document with a pre-defined
_id
property, meteor transactions package overwrites this with its own randomly - generated_id
valueThe following test demonstrates this bug