-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Avoid methods other than update! on OrderUpdater #1689
Conversation
cc5f02f
to
6edc4c3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking great so far. The thing I'm curious about is why methods like update_shipment_state
and update_payment_state
become public.
They were previously public. They're still a little too intertwined to be made private immediately. For example, in |
Thanks @jhawthorn I confused myself with the diffs. It was all the other stuff that became private, not those becoming public. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is beautiful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great improvement! Thanks 🍾
Indeed great! |
Instead of using a (soon to be) private method in OrderUpdater, this method now does what is asked of it. Tests adjustments one-by-one to ensure that they remain eligible.
ee4b50d
to
0944bf6
Compare
Previously refresh_rates was called from OrderUpdater on completed Orders. However, refresh_rates has no effect on completed orders, so this was pointless.
I don't think this is necessary, and has just been kept around. We should never get an unsaved shipment here. Even if we did, it would have unexpected behaviour as it would be saved later.
Previously, this was only called on completed orders. It's a simple and fast update, so we might as well perform it on every single update. This allows us to remove the need for Order#set_shipments_cost
0944bf6
to
aa1738d
Compare
This is now done as part of order.update! and is unnecessary
Previously OrderUpdateAttributes would call set_shipment_cost just in case any shipments had their selected shipping rate changed. set_shipment_cost would set the Shipment's cost from the shipping rate, and would update the order total, but wouldn't properly recalculate taxes or promotions. This commit removes the call to set_shipment_cost. Instead, order.update! should be called after OrderUpdateAttributes. This is done everywhere OrderUpdateAttributes is used in Solidus itself, and was already required (though not explicitly) for correct behaviour.
aa1738d
to
e5fce46
Compare
After update! => recalculate rename. ref: - solidusio#1689 - solidusio#2072
No description provided.