emberjs/ember.js — pull request #4555 by mixonic (2014-03-19 00:42:03+00:00)
Title: [BUGFIX beta] Only consider requests fired in a single test as pending

In order for the test waiter to work, it needs to keep track of ajax calls. In the past these calls were tracked by jQuery internally- eventually we began tracking them via ajaxSend and ajaxComplete. The simple implementation incremented and decremented a counter.

This solution was too naive, as it meant there was no way to disregard an xhr that had begun in testA, but was resolving in testB, from the pending count. testB would then hang on pending XHRs started in testA.

This commit introduces an array, reset on every setupForTesting, that keeps track of fired xhr requests. When a request completes, the array is searched for a matching send record. If one is found, the count is
decremented. If one is not found, then the response is ignored and the count left un-touched.

In this way, only XHRs from testA will hold up waits for testA, and only XHRs started in testB will hold up waits for testB.