(function() {
    module('BackboneBase.Request', {
        setup: function() {
            var requests = this.requests = [];
            this.Collection = Backbone.Collection.extend({url: 'https://api.github.com/repos/docyes/backbonebase/commits'});
            _.extend(this.Collection.prototype, BackboneBase.Request);
            this.xhr = sinon.useFakeXMLHttpRequest();  
            this.xhr.onCreate = function(xhr) {
                requests.push(xhr);
            };
        },
        
        teardown: function() {
            this.xhr.restore();
        }
    });

    test('enqueue', 6, function() {
        var collection = new this.Collection();
        collection.enqueueFetch({
            data: {req: 1}
        });
        collection.enqueueFetch({
            data: {req: 2}
        });
        collection.enqueueFetch({
            data: {req: 3}
        });
        equal(this.requests.length, 1, 'only one request other in queue');
        this.requests[0].respond(
            200, 
            {"Content-Type": "application/json" },
            '[{ "id": 1, "comment": "Hello world" }]'
        );
        equal(this.requests.length, 2, 'two requests as other completed');
        equal(collection.at(0).id, 1, 'collection first item has expected id');
        this.requests[1].respond(
            200, 
            {"Content-Type": "application/json" },
            '[{ "id": 2, "comment": "Hello world" }]'
        );
        equal(collection.at(0).id, 2, 'collection first item has expected id');
        equal(this.requests[0].url, 'https://api.github.com/repos/docyes/backbonebase/commits?req=1', 'first request was from the first enqueue call');
        equal(this.requests[1].url, 'https://api.github.com/repos/docyes/backbonebase/commits?req=3', 'second request was from the last enqueue call');
    });

})();


@@ -596,9 +596,10 @@
 e', 
-6
+11
 , fu
@@ -669,60 +669,184 @@
     
-collection.enqueueFetch(%7B%0A            data: %7Breq: 1%7D
+var success = sinon.spy();%0A        var error = sinon.spy();%0A        collection.enqueueFetch(%7B%0A            data: %7Breq: 1%7D,%0A            success: success,%0A            error: error
 %0A   
@@ -1390,32 +1390,478 @@
  expected id');%0A
+        equal(success.callCount, 1, 'success callback was called');%0A        equal(success.getCall(0).args%5B0%5D, collection, 'first success argument is collection');  %0A        deepEqual(success.getCall(0).args%5B1%5D, %5B%7B %22id%22: 1, %22comment%22: %22Hello world%22 %7D%5D, 'response is as expected');%0A        deepEqual(success.getCall(0).args%5B2%5D.data, %7Breq: 1%7D, 'options were proxied to callback');%0A        equal(error.callCount, 0, 'error callback was not called');%0A
         this.req

add tests for success callback proxy in enqueue request mixin