       onError: @expect =>
         @assertTrue true
 
+  testClientLocalCollection: [
+    ->
+      Meteor.call 'setLocalCollectionLimit', 10, @expect (error) =>
+          @assertFalse error, error
+  ,
+    ->
+      @assertSubscribeSuccessful 'localCollection', @expect()
+  ,
+    ->
+      @assertEqual LocalCollection.find({}).fetch(), []
+
+      for i in [0...10]
+        Meteor.call 'insertLocalCollection', {i: i}, @expect (error, documentId) =>
+          @assertFalse error, error
+          @assertTrue documentId
+  ,
+    ->
+      # To wait a bit for change to propagate.
+      Meteor.setTimeout @expect(), 100 # ms
+  ,
+    ->
+      @assertEqual LocalCollection.find({}).count(), 10
+
+      Meteor.call 'setLocalCollectionLimit', 5, @expect (error) =>
+        @assertFalse error, error
+
+      # To wait a bit for change to propagate.
+      Meteor.setTimeout @expect(), 100 # ms
+  ,
+    ->
+      @assertEqual LocalCollection.find({}).count(), 5
+
+      for i in [0...10]
+        Meteor.call 'insertLocalCollection', {i: i}, @expect (error, documentId) =>
+          @assertFalse error, error
+          @assertTrue documentId
+  ,
+    ->
+      # To wait a bit for change to propagate.
+      Meteor.setTimeout @expect(), 100 # ms
+  ,
+    ->
+      @assertEqual LocalCollection.find({}).count(), 5
+
+      Meteor.call 'setLocalCollectionLimit', 15, @expect (error) =>
+        @assertFalse error, error
+
+      # To wait a bit for change to propagate.
+      Meteor.setTimeout @expect(), 100 # ms
+  ,
+    ->
+      @assertEqual LocalCollection.find({}).count(), 15
+  ]
+
 # Register the test case.
 ClassyTestCase.addTest new ReactivePublishTestCase()

      projectedField = Fields.findOne userId

      {user, projectedField}

class ReactivePublishTestCase extends ClassyTestCase
  @testName: 'reactivepublish'


    Posts.find()

  Meteor.publish 'localCollection', ->
    @autorun (computation) =>
      LocalCollection.find({}, {sort: {i: 1}, limit: localCollectionLimit.get()}).observeChanges
        addedBefore: (id, fields, before) =>
          @added 'localCollection', id, fields
        changed: (id, fields) =>
          @changed 'localCollection', id, fields
        removed: (id) =>
          @removed 'localCollection', id

      @ready()

    return

  # We use our own insert method to not have latency compensation so that observeChanges
  # on the client really matches how databases changes on the server.
  Meteor.methods
    insertPost: (timestamp) ->
      check timestamp, Number

      Posts.insert
        timestamp: timestamp

    userAndProjection: (userId) ->
      user = Users.findOne userId,
        fields:
          posts: 1
