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

fix: update_shipped_shipments now cancels properly #4446

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

NewAlexandria
Copy link

@NewAlexandria NewAlexandria commented Jul 12, 2022

also refactor method parts for easier overwriting,
in a way that also encourages the use of super for the main method

Description
We were having this same issue, and I found the related issue when searching.

This solution may a fait bit more ruby algo gymnastics, but if it's acceptable I think it could make it easier to overwrite this pattern, again while still trying to encourage people to call super when overwriting the update_shipped_shipments method.

I also use an update_all call, to avoid N+1 queries.

I can include other comments, tests, etc, if this code looks like it'd be acceptable, and if anyone has suggestions. Until I confirmed receptiveness I didn't want to setup the test env. This PR is basically WIP, pending feedback.

Ref: #2947

Checklist:

  • I have followed Pull Request guidelines
  • I have added a detailed description into each commit message
  • I have updated Guides and README accordingly to this change (if needed)
  • I have added tests to cover this change (if needed)
  • I have attached screenshots to this PR for visual changes (if needed)

also refactor method parts for easier overwriting,
in a way that also encourages the use of super for the main method
@waiting-for-dev
Copy link
Contributor

Hey @NewAlexandria, it looks like tests are failing. Would you like to keep working on it? 🙂

@NewAlexandria
Copy link
Author

Hey @NewAlexandria, it looks like tests are failing. Would you like to keep working on it? 🙂

Sure, I'm glad to. As I mentioned in the PR body, I just wanted to make sure it seemed like a reasonable change that would be accepted given tests pass, etc.

I'll be slow to respond because we're pushing through to a launch, but I can commit to finishing this PR's tests, so it's mergeable

@kennyadsl kennyadsl added the type:bug Error, flaw or fault label Aug 22, 2022
@kennyadsl
Copy link
Member

Hey @NewAlexandria! Thanks for your contribution. Before evaluating the solution proposed (which looks good at a first pass), can you please add a failing spec for this bug to be sure this regression will never come back in the future? Thanks in advance!

@waiting-for-dev waiting-for-dev added the changelog:solidus_core Changes to the solidus_core gem label Aug 30, 2022
@NewAlexandria
Copy link
Author

I will get back to this PR. We're just in the middle of a release. Thanks.

end
end
def shipped_shippments_available_states
%w(shipped canceled)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sketch of thought on tests, pending what's there already:

  • these states
  • more valid states
  • no states
  • invalid state/s (the send fail. rescue it?)
  • idempotency? (maybe exclude those already in shipped_shippments_available_states ?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:solidus_core Changes to the solidus_core gem type:bug Error, flaw or fault
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants