funkensturm / ember-local-storage

The addon provides a storageFor computed property that returns a proxy and persists the changes to localStorage or sessionStorage. It ships with an ember-data adapter.
https://www.funkensturm.com/ember-local-storage/
MIT License
218 stars 76 forks source link

Ensure storage objects are destroyed on application teardown in tests #377

Closed Mikek2252 closed 8 months ago

Mikek2252 commented 8 months ago

Resolves #376 This is to ensure that storage objects are destroyed when the app is torn down in tests, currently objects created by storageFor are not destroyed after the test is torn down, i think this is because the class is returned by a computed property so is not destroyed by the parent that calls storageFor

Storage instances of adapters are destroyed but i have added owner injection to ensure that associateDestroyableChild does not error with a missing owner.

to ensure backward compatibility i have also added the destroyable polyfill

fsmanuel commented 8 months ago

@Mikek2252 released as v2.0.7. Thanks again for the fix!

Pixelik commented 8 months ago

All of my tests are now failing because of this change.

We have an instance-initializer that uses ember-local-storage and tries to update it and now it fails on every test saying something along the lines "..tried to set the property of a destroyed object" meaning the ember-local-storage is now destroyed when my instance-initializer tries to use it.

fsmanuel commented 8 months ago

@Pixelik oh no! Can you share the initializer?

Pixelik commented 8 months ago

I will try to find some time and provide you with the code - for now I've downgraded it's ok 🙏