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

This reverts commit 1aaea772f2.

Apparently tests fail after this commit. Not sure how that happened.
This commit is contained in:
Avital Oliver
2015-08-26 14:23:49 -07:00
parent 1aaea772f2
commit 5bf8885534
4 changed files with 3 additions and 65 deletions

View File

@@ -11,10 +11,6 @@ message for more details.
`JSON.parse` and `JSON.stringify`. (The last browser to not support JSON
natively was Internet Explorer 7.)
* Let `Meteor.call` within `observe` call server methods. Fixes #907
(and accidentally also #2691)
### Utilities
* New `beforeSend` option to `HTTP.call` on the client allows you to directly

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.isFalse(err);
test.equal(res, true);
done();
});
}
});
Meteor.call("insertIntoLocalCollection");
}
]);
}

View File

@@ -367,31 +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)
//
// XXX this shouldn't be necessary once #2315 is fixed (that
// is -- if we no longer run observe callbacks synchronously
// on Minimongo mutations).
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');
});