From 556aba22ac0f2d799c90caceb981c41359248642 Mon Sep 17 00:00:00 2001 From: Avital Oliver Date: Tue, 10 Jul 2012 13:32:39 -0700 Subject: [PATCH] Allow writes on a collection used in tests --- packages/livedata/livedata_test_service.js | 6 ++++++ packages/livedata/livedata_tests.js | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/livedata/livedata_test_service.js b/packages/livedata/livedata_test_service.js index 2984d73479..e27d65af1e 100644 --- a/packages/livedata/livedata_test_service.js +++ b/packages/livedata/livedata_test_service.js @@ -55,6 +55,12 @@ if (Meteor.is_server) { /*****/ Ledger = new Meteor.Collection("ledger"); +Ledger.allow({ + insert: function() { return true; }, + update: function() { return true; }, + remove: function() { return true; }, + fetch: [] +}); Meteor.startup(function () { if (Meteor.is_server) diff --git a/packages/livedata/livedata_tests.js b/packages/livedata/livedata_tests.js index ee1d8e5d22..405a243ef3 100644 --- a/packages/livedata/livedata_tests.js +++ b/packages/livedata/livedata_tests.js @@ -204,12 +204,14 @@ testAsyncMulti("livedata - basic method invocation", [ ]); + + var checkBalances = function (test, a, b) { var alice = Ledger.findOne({name: "alice", world: test.runId()}); var bob = Ledger.findOne({name: "bob", world: test.runId()}); test.equal(alice.balance, a); test.equal(bob.balance, b); -} +}; var onQuiesce = function (f) { if (Meteor.is_server) @@ -224,6 +226,7 @@ testAsyncMulti("livedata - compound methods", [ function (test) { if (Meteor.is_client) Meteor.subscribe("ledger", test.runId()); + Ledger.insert({name: "alice", balance: 100, world: test.runId()}); Ledger.insert({name: "bob", balance: 50, world: test.runId()}); }, @@ -236,7 +239,7 @@ testAsyncMulti("livedata - compound methods", [ var release = expect(); onQuiesce(function () { checkBalances(test, 90, 60); - Tinytest.defer(release); + Tinytest.defer(release); // XXX (why) do we need Tinytest.defer? }); }, function (test, expect) {