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

Remove unnecessary shipping rates callback #1905

Merged
merged 1 commit into from
Jun 21, 2017

Conversation

mamhoff
Copy link
Contributor

@mamhoff mamhoff commented May 13, 2017

The callback Spree::Order#ensure_available_shipping_rates was
explicitly written to be run before delivery. Running it before the
complete step leaves the order in the confirm state, but without
any shipments, and results in an error message does not make sense
in that context ("We were unable to calculate shipping rates"). In fact,
we have not even tried.

It's almost impossible to setup an order such that this callback would
actually trigger in a standard Solidus installation.

The commit that introduced the callback, 7ba53b2, intends to move line
item availability validations to the before complete callback, instead
of "all the time". That makes sense, but this callback has somehow sneaked
in there without any explanation of why its necessary.

I delete a model spec that was introduced in e7450ec, testing the behaviour
in question. The spec set the order up in a way that a normal checkout never would.
If you get through delivery and payment to the confirm step, and then
do literally anything to the order, it will be reset to either cart or address
state.

I edit another spec to test what the callback should actually do: Alert the user
that for their recently entered shipping address, no shipping rates can be calculated.

The callback `Spree::Order#ensure_available_shipping_rates` was
explicitly written to be run before delivery. Running it before the
`complete` step leaves the order in the `confirm` state, but without
any shipments, and results in an error message does not make sense
in that context ("We were unable to calculate shipping rates"). In fact,
we have not even tried.

It's almost impossible to setup an order such that this callback would
actually trigger in a standard Solidus installation.

The commit that introduced the callback, 7ba53b2, intends to move line
item availability validations to the before complete callback, instead
of "all the time". That makes sense, but this callback has somehow sneaked
in there without any explanation of why its necessary.

I delete a model spec that was introduced in e7450ec, testing the behaviour
in question. The spec set the order up in a way that a normal checkout never would.
If you get through delivery and payment to the confirm step, and then
do literally anything to the order, it will be reset to either cart or address
state.

I edit another spec to test what the callback should actually do: Alert the user
that for their recently entered shipping address, no shipping rates can be calculated.
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.

Code and behavior wise this is more correct now, but I don't know any of the rationale behind the former change.

@mamhoff
Copy link
Contributor Author

mamhoff commented May 17, 2017

I think this accidentally slipped into the codebase, actually.

Copy link
Contributor

@jhawthorn jhawthorn left a comment

Choose a reason for hiding this comment

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

Seems reasonable to me

@mamhoff mamhoff merged commit c293926 into master Jun 21, 2017
@mamhoff mamhoff deleted the remove-unnecessary-before-complete-callback branch June 21, 2017 16:05
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.

None yet

3 participants