-
-
Notifications
You must be signed in to change notification settings - Fork 725
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
Enterprises Controller: reset_distributor must be called before any call to memoized current_distributor #5501
Enterprises Controller: reset_distributor must be called before any call to memoized current_distributor #5501
Conversation
…tomer (that uses memoized current_distributor) is called after reset_distributor
…_distributor This validates bug openfoodfoundation#5496 is fixed
d3317e2
to
52810b0
Compare
I've tested the scenario in the issue:
looking good!
Is this intended? It's not clear to me while reading #5440 . In any case I don't think it is a blocker and we can merge this work as is and improve in a second round. At least we don't have a grumpy cat anymore :) |
I agree @RachL, this is good to go. If the OC is closed while on /checkout and I click the back button on the browser (like in Nick's video on the issue #5340 (comment)) I always land on the /shop page, and observe OC selector (if any left), but no flash message. I've searched a lot (as this was indicated as an outcome of a test case) and the only way I found to observe the flash was clicking directly in Shops, in the menu, instead of clicking back on the browser, from /checkout. So... How do you do it? (magic!) :-) Well, main point is probably that the release is not blocked any more 🎉 |
yeah, that redirect is not correct Rachel, can you replicate it? when you say "I am redirected", in what exact page are you and what do you do? page refresh or click somewhere? |
@luisramos0 @filipefurtad0 yes I can replicate. You need to do the following:
There the redirect to the home page with flash message happens.I also reproduced it while being on the cart page and trying to go to the checkout page after closing the OC. I'm sorry, I didn't think we could have different behavior, so I didn't test the checkout page before. Now I get a snail while trying to checkout with an OC that closed while I was on the checkout page...might be my internet connexion, I will retry in the morning... |
Outch, wasn't my internet access, I could reproduce the snail this morning it's a 404 error: My test was: I had a user who was on /checkout, I closed the OC, then I made this user click on the checkout button at the bottom of the page. I ended up with a 404: However when I press the browser back button I indeed ended up with the shop open on the other OC, no flash message. Is that 404 something you saw earlier @filipefurtad0 ? |
Hey @RachL , Thanks for checking this again.
That's what I observe too - so, all good I think. |
@filipefurtad0 great! |
Hey, do we need a new issue for the redirect problem? I mean, if there are 2 OCs and the hub closes one of them the redirect should go to the order OC, not to /shops. |
Yes @luisramos0, |
What? Why?
Closes #5496
The bug was caused by a hidden logical problem created by memoized current_distributor, current_customer that uses current_distributor cant be called before reset_distributor, otherwise the original (and outdated) distributor was memoized and returned by current_distributor...
The new spec in enterprises_controller validates the problem is fixed.
Moving current_distributor and current_customer to a service would be awesome here but would take too much time because they are called from quite a few places.
What should we test?
Verify bug is resolved.
We should probably give it a simple validation of #5440 as well
Release notes
Fix stale data problem when navigating across different shops.