title: "Meteor.userId can only be invoked in method calls" in Meteor Method test
body: <p>I'm learning Meteor following basic "Todo tutorial" from official website. I have problem with the "Testing" step.
  I have basic test of one Method, it looks like this:</p>
  
  <pre><code>if (Meteor.isServer) {
      describe('Tasks', () =&gt; {
          describe('methods', () =&gt; {
              const userId = Random.id();
              let taskId;
  
              beforeEach(() =&gt; {
                  Tasks.remove({});
                  taskId = Tasks.insert({
                      text: 'test task',
                      createdAt: new Date(),
                      owner: userId,
                      username: 'tmeasday',
                  });
              });
  
              it('can delete owned task', () =&gt; {
                  const deleteTask = Meteor.server.method_handlers['tasks.remove'];
  
                  const invocation = { userId };
                  deleteTask.apply(invocation, [taskId]);
                  assert.equal(Tasks.find().count(), 0);
              });
          });
      });
  }
  </code></pre>
  
  <p>This test fails with error:</p>
  
  <pre><code>Error: Meteor.userId can only be invoked in method calls. Use this.userId in publish functions.
      at AccountsServer.userId (packages/accounts-base/accounts_server.js:82:13)
      at Object.Meteor.userId (packages/accounts-base/accounts_common.js:257:19)
      at Object.Meteor.methods.tasks.remove (imports/api/tasks.js:37:35)
      at Test.&lt;anonymous&gt; (imports/api/tasks.tests.js:27:28)
      at run (packages/practicalmeteor:mocha-core/server.js:34:29)
      at Context.wrappedFunction (packages/practicalmeteor:mocha-core/server.js:63:33)
  </code></pre>
  
  <p>IMO, this error message is controversial, because it says about mistake I didn't make, because as I can see from line 4 in the error message, stacktrace points to the Method declaration body, this one:</p>
  
  <pre><code>'tasks.remove' (taskId) {
          check(taskId, String);
  
          const task = Tasks.findOne(taskId);
          if (task.owner !== Meteor.userId()) { // &lt;- ERROR MESSAGE POINTS TO THIS LINE
              // If the task is private, make sure only the owner can delete it
              throw new Meteor.Error('not-authorized');
          }
  
          Tasks.remove(taskId);
      },
  </code></pre>
  
  <p>There is 1 difference between tutorial code and my one: I removed the condition <code>!todo.private</code> from my <code>if</code> statements, so in the original tutorial they look like this:
  <code>if (!task.private &amp;&amp; task.owner !== Meteor.userId()) {...</code>
  IMO, this change makes the test reach the expression where it fails, because with the original code the test passes.</p>
  
  <p>I also mentioned that changing <code>Meteor.userId()</code> to <code>this.userId</code> makes the test pass and the app also looks to work like before.</p>
  
  <p>So, my question basically is: why the error message shows me controversial (IMO) info and what is the difference between using <code>this.userId</code> and <code>Meteor.userId()</code> in Methods?</p>
  
  <p>My full "Todo tutorial" project code can be found at: <a href="https://github.com/kemsbe/simple-todo" rel="nofollow noreferrer">https://github.com/kemsbe/simple-todo</a></p>