Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle subscriptions with deleted products #133

Closed
aldesantis opened this issue Jun 22, 2020 · 5 comments · Fixed by #211
Closed

Handle subscriptions with deleted products #133

aldesantis opened this issue Jun 22, 2020 · 5 comments · Fixed by #211
Assignees
Labels
bug Describes or fixes a bug.

Comments

@aldesantis
Copy link
Member

When a product is soft-deleted, it should also be removed from all active subscriptions, or perhaps we shouldn't allow deleting a product that has active subscriptions associated.

@aldesantis aldesantis added the bug Describes or fixes a bug. label Jun 22, 2020
@stale
Copy link

stale bot commented Aug 21, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix Will not be fixed. label Aug 21, 2020
@stale
Copy link

stale bot commented Oct 21, 2020

This issue has been automatically marked as stale because it has not had recent activity. It might be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Oct 21, 2020
@luca-landa luca-landa self-assigned this Feb 5, 2021
@luca-landa luca-landa removed stale wontfix Will not be fixed. labels Feb 5, 2021
@luca-landa
Copy link
Contributor

luca-landa commented Feb 5, 2021

Since we can't assume the subscribable class will always be a subclass of Spree::Variant, it may be harder to fix subscriptions on subscribable deletion.
Moreover, it may be difficult and/or risky trying to prevent its deletion, so I think we should allow their deletion.

If we want to allow it, I see two main ways:

  • handle the case while processing the subscription, checking for subscribables existence and removing them before processing, if needed
  • handle the case in a (IMHO) cleaner way through decoration of the subscribable class.
    • in that case we could apply the decoration only if the class is a Spree::Variant, or maybe the restriction could be that it needs to be an ActiveRecord model and then hook up the fix on its after_deletion or after_discard callbacks.

Any opinions or suggestions on possibilities I'm missing?

@aldesantis
Copy link
Member Author

@luca-landa thanks for the analysis here! I think removing the variant from any associated subscriptions is the right way to go here. I also think we should only do this when we're dealing with Spree::Variant, and just delegate the logic to the user in case they're using a custom subscribable class (which is unlikely, anyway).

@luca-landa
Copy link
Contributor

does it make sense to delete the Spree::Variant from every subscription? Or should it be removed from active subscriptions only? (what about soft-deleting it from every subscription?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Describes or fixes a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants