diff --git a/History.md b/History.md index 19efb7725e..f83f94907f 100644 --- a/History.md +++ b/History.md @@ -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 diff --git a/packages/minimongo/call_in_observe_test.js b/packages/minimongo/call_in_observe_test.js deleted file mode 100644 index fb0ac4a1ec..0000000000 --- a/packages/minimongo/call_in_observe_test.js +++ /dev/null @@ -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"); - } - ]); -} diff --git a/packages/minimongo/minimongo.js b/packages/minimongo/minimongo.js index bc5afdbb70..236a759629 100644 --- a/packages/minimongo/minimongo.js +++ b/packages/minimongo/minimongo.js @@ -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); diff --git a/packages/minimongo/package.js b/packages/minimongo/package.js index ea71d03036..8e23ae2b44 100644 --- a/packages/minimongo/package.js +++ b/packages/minimongo/package.js @@ -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'); });