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

Avoid methods other than update! on OrderUpdater #1689

Merged
merged 14 commits into from
Mar 21, 2017

Conversation

jhawthorn
Copy link
Contributor

No description provided.

@jhawthorn jhawthorn added the WIP label Jan 23, 2017
@jhawthorn jhawthorn force-pushed the order_update_private branch from cc5f02f to 6edc4c3 Compare January 23, 2017 22:34
@jhawthorn jhawthorn changed the title [WIP] Avoid methods other than update! on OrderUpdater Avoid methods other than update! on OrderUpdater Jan 25, 2017
@jhawthorn jhawthorn removed the WIP label Jan 25, 2017
Copy link
Member

@gmacdougall gmacdougall left a 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.

@jhawthorn
Copy link
Contributor Author

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 Order#finalize! both are called with intermediate work being done in-between.

@gmacdougall
Copy link
Member

Thanks @jhawthorn

I confused myself with the diffs. It was all the other stuff that became private, not those becoming public.

Copy link
Contributor

@mamhoff mamhoff left a comment

Choose a reason for hiding this comment

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

This is beautiful.

Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

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

Great improvement! Thanks 🍾

@mtomov
Copy link
Contributor

mtomov commented Mar 15, 2017

Indeed great!

@jhawthorn jhawthorn force-pushed the order_update_private branch from ee4b50d to 0944bf6 Compare March 21, 2017 22:25
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
@jhawthorn jhawthorn force-pushed the order_update_private branch from 0944bf6 to aa1738d Compare March 21, 2017 22:31
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.
@jhawthorn jhawthorn force-pushed the order_update_private branch from aa1738d to e5fce46 Compare March 21, 2017 22:55
@jhawthorn jhawthorn merged commit 84213cc into solidusio:master Mar 21, 2017
elia added a commit to elia/solidus that referenced this pull request May 10, 2019
After update! => recalculate rename.

ref:
- solidusio#1689
- solidusio#2072
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants