Revert "Let Meteor.call within observe call server methods."

This reverts commit b2cb10ef20.

Going to squash and re-commit
This commit is contained in:
Avital Oliver
2015-08-26 12:35:40 -07:00
parent a80185846a
commit 2efd196d91
3 changed files with 3 additions and 57 deletions

View File

@@ -1,34 +0,0 @@
// This file is a regression test for https://github.com/meteor/meteor/issues/907
Meteor.methods({
isRunningOnServer: function () {
return Meteor.isServer;
},
insertIntoLocalCollection: function () {
if (Meteor.isClient) {
LocalCollection.insert({});
}
}
});
if (Meteor.isClient) {
var LocalCollection = new Meteor.Collection(null);
testAsyncMulti("Meteor.call inside observe sends method to server", [
function (test, expect) {
var done = expect();
LocalCollection.find().observe({
added: function () {
Meteor.call("isRunningOnServer", function (err, res) {
test.equal(err, undefined);
test.equal(res, true);
done();
});
}
});
Meteor.call("insertIntoLocalCollection");
}
]);
}

View File

@@ -367,27 +367,9 @@ _.extend(LocalCollection.Cursor.prototype, {
if (self.collection.paused)
return;
// Wrap a function as to not seem as if it's running as part
// of a method stub. One important consequence is that you'll
// be able to call `Meteor.call` within these wrapped
// functions and actually end up calling a server method (as
// opposed to just a client stub)
var wrapNotInMethodStub = function (f) {
// It is strange that we refer to the `ddp` package directly
// here. This pattern appears elsewhere in the code, but
// should be abstracted away or re-thought.
if (Package.ddp) {
return function () {
Package.ddp.DDP._CurrentInvocation.withValue(null, f);
};
} else {
return f;
}
};
self.collection._observeQueue.queueTask(wrapNotInMethodStub(function () {
f.apply(context, args);
}));
self.collection._observeQueue.queueTask(function () {
f.apply(context, args);
});
};
};
query.added = wrapCallback(options.added);

View File

@@ -39,11 +39,9 @@ Package.onUse(function (api) {
Package.onTest(function (api) {
api.use('minimongo', ['client', 'server']);
api.use('test-helpers', 'client');
api.use('ddp'); // for testing interaction between `Meteor.call` and `observe`
api.use(['tinytest', 'underscore', 'ejson', 'ordered-dict',
'random', 'tracker', 'reactive-var', 'mongo-id']);
api.addFiles('minimongo_tests.js', 'client');
api.addFiles('wrap_transform_tests.js');
api.addFiles('minimongo_server_tests.js', 'server');
api.addFiles('call_in_observe_test.js');
});