goodeggs / angular-cached-resource

An AngularJS module to interact with RESTful resources, even when browser is offline
MIT License
216 stars 29 forks source link

[bugfix] avoid TypeError when resolving enqueued write requests from cache #6

Closed jtomaszewski closed 10 years ago

jtomaszewski commented 10 years ago

My scenario:

  1. Issue a $save on a resource and bind some promise callbacks to it (by .then or .catch)
  2. Reopen browser (so resoure will be resaved from cache)
  3. Try to $save again manually

This will make this error:

Uncaught TypeError: Cannot read property '$promise' of undefined

This fixes it.

hazeledmands commented 10 years ago

Thanks for finding this! I wonder if it's worth setting up something like Protractor to test this scenario...

jtomaszewski commented 10 years ago

I think we can test this scenario without Protractor.

I just didn't manage to write any test yet. because I'm still not sure about the exact scenario. I'll try to do that later.

hazeledmands commented 10 years ago

Check out 1312fd7 for a test that recreates this scenario. Thanks again! :smile_cat: