FacultyCreative / ngActiveResource

Connects business objects and REST web services for Angular.js
255 stars 34 forks source link

Remove async dependency in favor of promises #56

Open marshall007 opened 10 years ago

marshall007 commented 10 years ago

It appears that async is relied upon for just two calls to async.series(). Here's my attempt at replicating this behavior using a promise chain. There's still one failing test case that I can't get to pass so I'm hoping someone more familiar with the internals can take a look:

PhantomJS 1.9.7 (Mac OS X) ActiveResource Querying base#where utilizes findURL by default has associated method #all that returns all instances FAILED
    Error: Unexpected request: GET http://api.faculty.com/grid-controllers?system_id=8
    No more request expected
        at $httpBackend (/Users/marshall/Projects/ngActiveResource/bower_components/angular-mocks/angular-mocks.js:1179)
        at sendReq (/Users/marshall/Projects/ngActiveResource/bower_components/angular/angular.js:8181)
        at /Users/marshall/Projects/ngActiveResource/bower_components/angular/angular.js:7921
        at /Users/marshall/Projects/ngActiveResource/bower_components/angular/angular.js:11319
        at /Users/marshall/Projects/ngActiveResource/bower_components/angular/angular.js:11319
        at /Users/marshall/Projects/ngActiveResource/bower_components/angular/angular.js:11405
        at /Users/marshall/Projects/ngActiveResource/bower_components/angular/angular.js:12412
        at /Users/marshall/Projects/ngActiveResource/bower_components/angular/angular.js:12224
        at /Users/marshall/Projects/ngActiveResource/bower_components/angular/angular.js:12516
        at done (/Users/marshall/Projects/ngActiveResource/bower_components/angular/angular.js:8204)
        at handleResponse (/Users/marshall/Projects/ngActiveResource/bower_components/angular-mocks/angular-mocks.js:1131)
        at /Users/marshall/Projects/ngActiveResource/bower_components/angular-mocks/angular-mocks.js:1448
        at /Users/marshall/Projects/ngActiveResource/spec/angular-resource/active-resource.spec.js:1332
PhantomJS 1.9.7 (Mac OS X): Executed 329 of 329 (1 FAILED) (2.087 secs / 1.957 secs)
marshall007 commented 10 years ago

After looking into this further, I think this test case fails because the existing behavior is bugged. Calling .all() or .where() with no parameters is going to default to { lazy: false }. As a result, isn't the expected behavior in this test to eagerly fetch the hasOne relationships (i.e. the GridController associated with each system) as well?

hyperborea commented 10 years ago

+1 I'd love to drop the dependency to async and meld isn't used anywhere either.